pydoc3.5 borks on my Mac
Peter Otten
__peter__ at web.de
Sun Feb 1 14:35:39 EST 2015
Skip Montanaro wrote:
> On Sun, Feb 1, 2015 at 11:20 AM, Peter Otten <__peter__ at web.de> wrote:
>> Try setting the environment variable
>>
>> PYTHONIOENCODING=UTF-8
>
> Thanks, but that didn't help. I still get the same exception.
The pager is invoked by os.popen(), and after some digging I find that it
uses a io.TestIOWrapper() to write the help text. This in turn uses
locale.getpreferredencoding(False), i. e. you were right to set LANG and
PYTHONIOENCODING is not relevant.
I'm able to provoke what I think causes your problem on linux with Python 3.4:
$ LANG=en_US.utf-8 python3 -c 'import os; os.popen("cat", "w").write("\xe4\n")'
รค
$ LANG=en_US.ascii python3 -c 'import os; os.popen("cat", "w").write("\xe4\n")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 0: ordinal not in range(128)
Perhaps LANG=en_US.utf-8 is not understood by your system (uppercase UTF-8? I really don't know the Mac).
What does
$ LANG=en_US.UTF-8 python3 -c 'import locale; print(locale.getpreferredencoding(False))'
UTF-8
print?
More information about the Python-list
mailing list