Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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; 'encoded': 0.07; 'python3': 0.07; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Why': 0.09; 'python': 0.11; 'bug': 0.12; 'jan': 0.12; 'codecs': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'subject:already': 0.16; 'subject:unicode': 0.16; 'exception': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'instead.': 0.24; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'raise': 0.29; "doesn't": 0.30; "skip:' 10": 0.31; 'agreed.': 0.31; 'subject:that': 0.31; 'linux': 0.33; 'sense': 0.34; 'doing': 0.36; 'subject:?': 0.36; 'should': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'received:fios.verizon.net': 0.84; '\xe2\x82\xac': 0.84; '2013,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Why does unicode-escape decode escape symbols that are already escaped? Date: Sun, 10 May 2015 13:00:52 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431277269 news.xs4all.nl 2872 [2001:888:2000:d::a6]:34127 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90299 On 5/10/2015 11:53 AM, Somelauw . wrote: > In Python 3, decoding "=E2=82=AC" with unicode-escape returns '=C3=A2\x= 82=C2=AC' which in > my opinion doesn't make sense. Agreed. I think this is a bug in that it should raise an exception=20 instead. Decoding a string only makes sense for rot-13 > The =E2=82=AC already is decoded; if it were encoded it would look like= this: > '\u20ac'. > So why is it doing this? > $ python3 -S > Python 3.3.3 (default, Nov 27 2013, 17:12:35) > [GCC 4.8.2] on linux > >>> import codecs > >>> codecs.decode('=E2=82=AC', 'unicode-escape') > '=C3=A2\x82=C2=AC' > >>> codecs.encode('=E2=82=AC', 'unicode-escape') > b'\\u20ac' --=20 Terry Jan Reedy