STINNER Victor <victor.stin...@haypocalc.com> added the comment:

>  All I'm trying to do is run different versions of Python on the same machine 
> from the command line.
> Some code inside Python now "break" if Python 3.1 is started with Code Page 
> 65001.

Yes, this issue can be seen as a regression introduced in Python 3.

> I fully understand the change between Python 2.7 and 3.1 were probably due to 
> trying to fix issue #1602 (or some other related issue).

Python 2 and 3 are very different. In Python 2, print "abc" writes a 
byte string to stdout, whereas print("abc") writes a Unicode string to 
stdout. Byte strings and character strings are two different things ;-)

Python 3 now uses Unicode by default and it requires a codec to encode 
strings to stdout. If your program don't output anything to stdout, use 
pythonw.exe instead of python.exe.

The issue #1602 is not specific to Python 3: Python 2 is unable to 
display correctly Unicode strings in the Windows console. It's less 
important in Python 2, because most developers use the default string 
type which is a byte string.

> Setting my cmd.exe code page to 65001 shouldn't mean a thing to Python if it 
> can't associate it with an encoding.  It could, at least, just switch to 
> 7-Bit ASCII and proceed on.  That would be better than failing!

I don't like this idea. In Python, we try to not ignore errors, but try 
instead to fix them or at least fail with an error message (the user is 
responsible to fix it or use a workaround). To fix this issue, we have 
to implement a cp65001 codec for Python or to work directly in Unicode 
using WriteConsole.

If you cannot help to implement one of this option, you can use a 
workaround:

  - don't change the codepage
  - use PYTHONIOENCODING=utf-8

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12632>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to