Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.04; 'encoding': 0.05; 'subject:Python': 0.06; 'python3': 0.07; 'utf-8': 0.07; 'uses.': 0.09; 'posted': 0.15; 'ascii,': 0.16; 'bytes).': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'subject:Dev': 0.16; 'subject:Unicode': 0.16; 'subject:exception': 0.16; 'traceback.': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'unicode': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'errors': 0.30; "i'm": 0.30; 'usually': 0.31; 'default,': 0.31; 'file': 0.32; 'supposed': 0.32; 'open': 0.33; 'says': 0.33; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'scheme': 0.36; 'error.': 0.37; 'message-id:@gmail.com': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'tell': 0.60; 'full': 0.61; 'invalid': 0.68; 'default': 0.69; 'do:': 0.91; 'whereas': 0.91 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Sun, 30 Nov 2014 21:33:28 -0700 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: [Python-Dev] Unicode decode exception References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417408427 news.xs4all.nl 2910 [2001:888:2000:d::a6]:58352 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3619 X-Received-Body-CRC: 3953621515 Xref: csiph.com comp.lang.python:81743 On 11/30/2014 09:19 PM, balaji marisetti wrote: > The default encoding is "UTF-8". It works if I do: > > with open("filename", errors="ignore") as f: > .... > > So I think Python2, by default, ignores all errors whereas Python3 doesn't Do you mean that the file is supposed to be utf-8 but isn't? Because if it is, you need to tell open about it in Python3 to make sure that's the decoding scheme it uses. Otherwise you will see this decode error. Also I'm not sure you posted the full traceback. Usually a UnicodeDecodeError says something about an invalid byte while using a specific unicode decoding scheme (say, ASCII, which can't handle utf-8 bytes).