Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; 'python3': 0.07; 'utf-8': 0.07; 'apis': 0.09; 'encode': 0.09; 'fixed,': 0.09; 'screen.': 0.09; 'used.': 0.09; 'windows,': 0.09; 'python': 0.11; 'bug': 0.12; 'changes': 0.15; 'windows': 0.15; 'codec': 0.16; 'patches': 0.16; 'skip:b 80': 0.16; 'skip:p 90': 0.16; 'wrote:': 0.18; "hasn't": 0.19; 'properly': 0.19; 'example': 0.22; 'issue.': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'handling': 0.26; 'possibly': 0.26; 'skip:" 30': 0.26; 'skip:" 20': 0.27; 'header :In-Reply-To:1': 0.27; 'tried': 0.27; 'url:bugs': 0.29; 'am,': 0.29; 'character': 0.29; 'patch': 0.29; "doesn't": 0.30; 'characters': 0.30; 'database,': 0.30; 'program,': 0.31; 'getting': 0.31; 'correctly.': 0.31; 'fixing': 0.31; 'follows': 0.31; 'file': 0.32; 'handled': 0.32; 'url:python': 0.33; '(most': 0.33; 'could': 0.34; "can't": 0.35; 'display': 0.35; 'good.': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'data,': 0.36; 'in.': 0.36; 'received:10.0': 0.36; 'url:org': 0.36; 'received:10': 0.37; 'skip:& 10': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'ensure': 0.60; 'days': 0.60; 'skip:u 10': 0.60; 'read': 0.60; 'future': 0.60; 'skip:c 50': 0.60; 'received:unknown': 0.61; 'hope': 0.61; 'ago,': 0.61; 'field': 0.63; 'july': 0.63; 'frank': 0.68; 'insight': 0.68; 'received:bluehost.com': 0.68; 'integrated': 0.69; 'saw': 0.77; '2014,': 0.84; 'characters,': 0.84; 'experiment': 0.84; 'hardest': 0.91; 'serious': 0.97 X-Authority-Analysis: v=2.1 cv=fudPOjIf c=1 sm=1 tr=0 a=bHMQH+OLnPEWGwbUEerQzQ==:117 a=bHMQH+OLnPEWGwbUEerQzQ==:17 a=cNaOj0WVAAAA:8 a=f5113yIGAAAA:8 a=tcnv99F1KMcA:10 a=_1ukbFuioP8A:10 a=aDqhzxAoLLkA:10 a=9HSTQGAzAAAA:8 a=7j9GTTBHwvYA:10 a=3zz60rSFY80A:10 a=r77TgQKjGQsHNAKrUKIA:9 a=9iDbn-4jx3cA:10 a=cKsnjEOsciEA:10 a=W4ub2mWhAAAA:8 a=8AHkEIZyAAAA:8 a=ACaMN0wT8iELmI2uSaYA:9 a=QEXdDO2ut3YA:10 a=hyQZZy9n7qMA:10 a=TSbVqHtbAAAA:8 a=RhgJyRok_HdrJ-Xh_ZYA:9 a=HPD008Ji55EC4ZtH:21 a=_W_S_7VecoQA:10 Date: Fri, 01 Aug 2014 23:18:47 -0700 From: Glenn Linderman User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> In-Reply-To: Content-Type: multipart/alternative; boundary="------------020102020609010206010903" X-Identified-User: {1756:box1033.bluehost.com:areliabl:nevcal.com} {sentby:smtp auth 75.141.226.92 authed with test@nevcal.com} 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: 108 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406960354 news.xs4all.nl 2948 [2001:888:2000:d::a6]:37028 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75515 This is a multi-part message in MIME format. --------------020102020609010206010903 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/16/2014 7:27 AM, Frank Millman wrote: > I just tried an experiment in my own project. Ned Batchelder, in his > Pragmatic Unicode presentation, http://nedbatchelder.com/text/unipain.html, > suggests that you always have some unicode characters in your data, just to > ensure that they are handled correctly. He has a tongue-in-cheek example > which spells the word PYTHON using various exotic unicode characters. I used > this to populate a field in my database, to see if it would display in my > browser-based client. > > The hardest part was getting it in. There are 6 characters, but utf-8 > requires 16 bytes to store it - > > b'\xe2\x84\x99\xc6\xb4\xe2\x98\x82\xe2\x84\x8c\xc3\xb8\xe1\xbc\xa4'.decode('utf-8') > > However, that was it. Without any changes to my program, it read it from the > database and displayed it on the screen. IE8 could only display 2 out of the > 6 characters correctly, and Chrome could display 5 out of 6, but that is a > separate issue. Python3 handled it perfectly. wrapping the above in a print(), on Windows, I get: Traceback (most recent call last): File "D:\my\py\python-utf8.py", line 1, in print(b'\xe2\x84\x99\xc6\xb4\xe2\x98\x82\xe2\x84\x8c\xc3\xb8\xe1\xbc\xa4'.decode('utf-8')) File "C:\Python33\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-5: character maps to So Python3 doesn't handle it perfectly on Windows. And I saw someone blame the Windows console for that... but the Windows console can properly display all those characters if the proper APIs are used. The bug is 7 years old: http://bugs.python.org/issue1602 and hasn't been fixed, although the technology for fixing it is available, and various workarounds (with limitations) have been available for 5 years, and patches have been available for 3 years that work pretty good. However, just a few days ago, 26 July 2014, Drekin had an insight that may possibly lead to a patch that will work well enough to be integrated into some future version of Python... I hope he follows up on it. This is a serious limitation, and it is, and always has been, a bug in Python 3 Unicode handling on Windows. --------------020102020609010206010903 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 7/16/2014 7:27 AM, Frank Millman wrote:
I just tried an experiment in my own project. Ned Batchelder, in his 
Pragmatic Unicode presentation, http://nedbatchelder.com/text/unipain.html, 
suggests that you always have some unicode characters in your data, just to 
ensure that they are handled correctly. He has a tongue-in-cheek example 
which spells the word PYTHON using various exotic unicode characters. I used 
this to populate a field in my database, to see if it would display in my 
browser-based client.

The hardest part was getting it in. There are 6 characters, but utf-8 
requires 16 bytes to store it -

    b'\xe2\x84\x99\xc6\xb4\xe2\x98\x82\xe2\x84\x8c\xc3\xb8\xe1\xbc\xa4'.decode('utf-8')

However, that was it. Without any changes to my program, it read it from the 
database and displayed it on the screen. IE8 could only display 2 out of the 
6 characters correctly, and Chrome could display 5 out of 6, but that is a 
separate issue. Python3 handled it perfectly.

wrapping the above in a print(), on Windows, I get:

Traceback (most recent call last):
  File "D:\my\py\python-utf8.py", line 1, in <module>
    print(b'\xe2\x84\x99\xc6\xb4\xe2\x98\x82\xe2\x84\x8c\xc3\xb8\xe1\xbc\xa4'.decode('utf-8'))
  File "C:\Python33\lib\encodings\cp437.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-5: character maps to <undefined>

So Python3 doesn't handle it perfectly on Windows.  And I saw someone blame the Windows console for that... but the Windows console can properly display all those characters if the proper APIs are used. The bug is 7 years old: http://bugs.python.org/issue1602 and hasn't been fixed, although the technology for fixing it is available, and various workarounds (with limitations) have been available for 5 years, and patches have been available for 3 years that work pretty good. However, just a few days ago, 26 July 2014, Drekin had an insight that may possibly lead to a patch that will work well enough to be integrated into some future version of Python... I hope he follows up on it. This is a serious limitation, and it is, and always has been, a bug in Python 3 Unicode handling on Windows.
--------------020102020609010206010903--