Received: by 10.66.77.101 with SMTP id r5mr1443183paw.27.1343304340309; Thu, 26 Jul 2012 05:05:40 -0700 (PDT) Path: c10ni37310pbw.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: jaroslav.dob...@gmail.com Newsgroups: comp.lang.python Subject: Re: catch UnicodeDecodeError Date: Thu, 26 Jul 2012 04:58:03 -0700 (PDT) Organization: http://groups.google.com Lines: 16 Message-ID: References: <04f7ff8d-9881-4a04-ab2e-b5573b5f3cd1@googlegroups.com> <38f5cdaf-c021-4ccd-8fcb-c68b21d3aeb2@w24g2000vby.googlegroups.com> <17bf754d-b1e9-4bb7-bf42-190325ee969a@q29g2000vby.googlegroups.com> NNTP-Posting-Host: 2001:4ca0:4f01:1:230:5ff:fed2:39da Mime-Version: 1.0 X-Trace: posting.google.com 1343304340 14898 127.0.0.1 (26 Jul 2012 12:05:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 26 Jul 2012 12:05:40 +0000 (UTC) Cc: python-l...@python.org In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2001:4ca0:4f01:1:230:5ff:fed2:39da; posting-account=74hy7woAAACQhc1ciracbLCiA9j-fl9e User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 > that tells you the exact code line where the error occurred. No need to > look around. You are right: try: for line in f: do_something() except UnicodeDecodeError: do_something_different() does exactly what one would expect it to do. Thank you very much for pointing this out and sorry for all the posts. This is one of the days when nothing seems to work and when I don't seem to able to read the simplest error message.