Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'cpython': 0.05; 'failing': 0.05; 'wrapped': 0.07; 'exits': 0.09; 'information?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '2.7': 0.13; 'properly': 0.15; '3.2,': 0.16; 'clause.': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'message-id:@dough.gmane.org': 0.16; 'occurred.': 0.16; 'originate': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.17; 'bytes': 0.17; 'else,': 0.17; 'stefan': 0.17; '>>>': 0.18; 'tells': 0.22; 'statement': 0.23; 'somewhere': 0.24; 'thus': 0.24; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.28; 'lines': 0.28; 'end,': 0.29; 'far.': 0.29; 'source': 0.29; 'error': 0.30; 'code': 0.31; 'impression': 0.33; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'received:org': 0.36; 'except': 0.36; 'but': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'skip:u 10': 0.60; 'leading': 0.61 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: catch UnicodeDecodeError Date: Thu, 26 Jul 2012 14:24:40 +0200 References: <04f7ff8d-9881-4a04-ab2e-b5573b5f3cd1@googlegroups.com> <38f5cdaf-c021-4ccd-8fcb-c68b21d3aeb2@w24g2000vby.googlegroups.com> <17bf754d-b1e9-4bb7-bf42-190325ee969a@q29g2000vby.googlegroups.com> <50113568.9030006@phihag.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: fw-snc-frn5-de01.fw.telefonica.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 In-Reply-To: <50113568.9030006@phihag.de> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343305491 news.xs4all.nl 6840 [2001:888:2000:d::a6]:33263 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26086 Philipp Hagemeister, 26.07.2012 14:17: > On 07/26/2012 01:15 PM, Stefan Behnel wrote: >>> exits with a UnicodeDecodeError. >> ... that tells you the exact code line where the error occurred. > > Which property of a UnicodeDecodeError does include that information? > > On cPython 2.7 and 3.2, I see only start and end, both of which refer to > the number of bytes read so far. Read again: "*code* line". The OP was apparently failing to see that the error did not originate in the source code lines that he had wrapped with a try-except statement but somewhere else, thus leading to the misguided impression that the exception was not properly caught by the except clause. Stefan