Issue 6625: UnicodeEncodeError on pydoc's CLI (original) (raw)
Created on 2009-08-02 13:00 by christoph, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (10)
Author: Christoph Burgmer (christoph)
Date: 2009-08-02 13:00
pydoc fails with a UnicodeEncodeError for properly specified Unicode docstrings (u"""...""") on the command line interface.
See attached patch that encodes the output with the system's encoding.
Author: Gabriel Genellina (ggenellina)
Date: 2009-08-05 02:00
After applying your patch, are string (not unicode) docstrings still being handled properly? Adding a test case (in Lib/test/test_pydoc.py) would be nice too.
Author: Christoph Burgmer (christoph)
Date: 2009-08-05 11:29
Here is a diff for test/test_pydoc.py (against Python2.6) which though doesn't trigger due to how Python handles output encoding. This test here will pass, but pydoc will still fail:
$ pydoc test/pydoc_mod.py > /dev/null Traceback (most recent call last): File "/usr/bin/pydoc", line 5, in 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)
Author: Torsten Landschoff (torsten) *
Date: 2010-02-22 10:26
This problem persists with current Python 2.7 trunk (I used hg mirror): 52aa81c14f87 (trunk) tip
I also checked with the py3k branch and it does not show this limitation. Just as one would have expected...
Author: Torsten Landschoff (torsten) *
Date: 2010-02-22 10:35
As Subversion is still the master repo (correct me if I am wrong), the hg version tested maps to r78290 in subversion on /trunk.
Author: Florent Xicluna (flox) *
Date: 2010-02-22 11:36
This patch do not work for me.
See the patch attached on duplicate bug #7625, with more tests: http://bugs.python.org/file15831/issue7675_pydoc_v2.diff
Author: Florent Xicluna (flox) *
Date: 2010-02-22 12:53
Patch with same tests as the previous one, but using better heuristic for output encoding (like Christoph patch). Added the "replace" error handling, if the output encoding cannot encode all characters.
Author: Akira Kitada (akitada) *
Date: 2014-01-13 06:40
I suppose this is a duplicate of #1065986.
Author: Berker Peksag (berker.peksag) *
Date: 2014-01-13 08:40
I suppose this is a duplicate of #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
Author: Torsten Landschoff (torsten) *
Date: 2014-01-13 10:56
I tested this as well and it seems to work now. :-) Thanks for fixing it!
History
Date
User
Action
Args
2022-04-11 14:56:51
admin
set
github: 50874
2014-01-13 10:56:30
torsten
set
messages: +
2014-01-13 08:40:41
berker.peksag
set
status: open -> closed
nosy: + berker.peksag
messages: +
resolution: out of date
stage: patch review -> resolved
2014-01-13 06:40:19
akitada
set
nosy: + akitada
messages: +
2012-07-21 13:50:21
flox
set
stage: needs patch -> patch review
2011-04-27 08:52:44
eric.araujo
set
nosy: + eric.araujo
versions: - Python 2.6
2010-11-02 20:36:51
vstinner
set
nosy: + vstinner
2010-08-01 19:42:07
flox
link
2010-02-22 12:53:07
flox
set
files: + issue6625_pydoc.diff
messages: +
2010-02-22 11:36:36
flox
set
priority: normal
type: behavior
components: + Library (Lib), - Extension Modules
versions: + Python 2.7, - Python 2.5
nosy: + flox
messages: +
stage: needs patch
2010-02-22 11:06:55
flox
link
2010-02-22 10:35:37
torsten
set
messages: +
2010-02-22 10:26:18
torsten
set
nosy: + torsten
messages: +
2009-08-05 11:29:49
christoph
set
files: + pydoc_unicode_testcase_notworking.diff
messages: +
2009-08-05 02:00:31
ggenellina
set
nosy: + ggenellina
messages: +
2009-08-02 13:00:46
christoph
create