New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnicodeEncodeError on pydoc's CLI #50874
Comments
pydoc fails with a UnicodeEncodeError for properly specified Unicode See attached patch that encodes the output with the system's encoding. |
After applying your patch, are string (not unicode) docstrings still |
Here is a diff for test/test_pydoc.py (against Python2.6) which though $ pydoc test/pydoc_mod.py > /dev/null
Traceback (most recent call last):
File "/usr/bin/pydoc", line 5, in <module>
pydoc.cli()
File "/usr/lib/python2.5/pydoc.py", line 2226, in cli
help.help(arg)
File "/usr/lib/python2.5/pydoc.py", line 1691, in help
else: doc(request, 'Help on %s:')
File "/usr/lib/python2.5/pydoc.py", line 1482, in doc
pager(title % desc + '\n\n' + text.document(object, name))
File "/usr/lib/python2.5/pydoc.py", line 1300, in pager
pager(text)
File "/usr/lib/python2.5/pydoc.py", line 1398, in plainpager
sys.stdout.write(plain(text))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
position 936: ordinal not in range(128) |
This problem persists with current Python 2.7 trunk (I used hg mirror): I also checked with the py3k branch and it does not show this limitation. Just as one would have expected... |
As Subversion is still the master repo (correct me if I am wrong), the hg version tested maps to r78290 in subversion on /trunk. |
This patch do not work for me. See the patch attached on duplicate bug bpo-7625, with more tests: |
Patch with same tests as the previous one, but using better heuristic for output encoding (like Christoph patch). |
I suppose this is a duplicate of bpo-1065986. |
Yes, it is. I created a test file from the tests in issue6625_pydoc.diff and ran it on the current 2.7 branch. def foo():
u"""fooo bar
baz
\xfcnicode\u2026"""
return 42
def bar():
u"f\xfcr Elise"
return 11 |
I tested this as well and it seems to work now. :-) Thanks for fixing it! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: