[issue14986] print() fails on latin1 characters on OSX

Adrian Bastholm report at bugs.python.org
Sat Jun 2 22:34:37 CEST 2012


Adrian Bastholm <javahaxxor at gmail.com> added the comment:

Output in console:

Python 3.2.3 (v3.2.3:3d0686d90f55, Apr 10 2012, 11:25:50) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.stdout)
<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
>>> import os
>>> print([(k, os.environ[k]) for k in os.environ if k.startswith('LC')])
[('LC_CTYPE', 'UTF-8')]
>>> print([(k, os.environ[k]) for k in os.environ if k.startswith('LANG')])
[]
>>> import locale
>>> print(locale.getlocale())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/locale.py", line 524, in getlocale
    return _parse_localename(localename)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/locale.py", line 433, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
>>> print('\u00e5')
å
>>> print('\u0061\u030a')
å
**********************

Output from Eclipse:

<_io.TextIOWrapper name='<stdout>' mode='w' encoding='MacRoman'>
[]
[]
(None, None)
å
Traceback (most recent call last):
  File "/Users/adyhasch/Documents/PythonWorkspace/PatternRenamer/src/prenamer.py", line 70, in <module>
    print('\u0061\u030a')
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/encodings/mac_roman.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u030a' in position 1: character maps to <undefined>
************************************

I'm running PyDev ..

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14986>
_______________________________________


More information about the Python-bugs-list mailing list