classification
Title: help() doesn't accept unicode literals in built in docstrings
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: UnicodeEncodeError on pydoc's CLI
View: 6625
Assigned To: Nosy List: ezio.melotti, flox, pitrou, psd
Priority: normal Keywords: patch

Created on 2010-01-11 09:40 by psd, last changed 2010-02-22 11:06 by flox. This issue is now closed.

Files
File name Uploaded Description Edit
tudelut.py psd, 2010-01-11 09:40 a small test that reproduces the error
issue7675_pydoc_v2.diff flox, 2010-01-11 20:58 Patch, apply to trunk
Messages (6)
msg97584 - (view) Author: pablo stapff (psd) Date: 2010-01-11 09:40
We use umlaut in our docstrings and when we use the help() function to extract the documentation, the function reports an error:

UnicodeEncodeError: 'ascii' codec can't encode character....

Our docstrings are specified as unicode literals and the source file contains the line:

# -*- coding: utf-8 -*-


just import the module and make:

 help(tudelut.tudelut)
msg97585 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-11 11:07
Confirmed.

With Python 2:

>>> import pydoc
>>> pydoc.pipepager(u'tütdelüt\n', 'cat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./Lib/pydoc.py", line 1357, in pipepager
    pipe.write(text)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128)



With Python 3:

>>> import pydoc
>>> pydoc.pipepager('tütdelüt\n', 'cat')
tütdelüt
msg97590 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-11 16:43
The unicode text is sent to the subprocess without encoding.
It is encoded implicitly to ASCII (sys.getdefaultencoding()).

This patch performs explicit encoding.
Tests added.
msg97591 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-01-11 16:46
The patch should also work with 8-bit docstrings, and the tests should reflect both uses.
msg97604 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-11 20:53
New patch: backward compatibility preserved.
msg99720 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-02-22 11:06
It looks like a duplicate of #6625.
History
Date User Action Args
2010-08-01 19:42:07floxunlinkissue8994 superseder
2010-08-01 19:41:31floxlinkissue8994 superseder
2010-02-22 11:06:55floxsetstatus: open -> closed
resolution: duplicate
superseder: UnicodeEncodeError on pydoc's CLI
messages: + msg99720
2010-01-11 20:58:03floxsetfiles: + issue7675_pydoc_v2.diff
2010-01-11 20:57:49floxsetfiles: - issue7675_pydoc_v2.diff
2010-01-11 20:53:30floxsetfiles: + issue7675_pydoc_v2.diff

messages: + msg97604
2010-01-11 20:51:26floxsetfiles: - issue7675_pydoc.diff
2010-01-11 16:46:22pitrousetnosy: + pitrou
messages: + msg97591
2010-01-11 16:43:48floxsetfiles: + issue7675_pydoc.diff
versions: + Python 3.2
messages: + msg97590

keywords: + patch
stage: needs patch -> patch review
2010-01-11 13:09:14ezio.melottisetnosy: + ezio.melotti
2010-01-11 11:07:58floxsetpriority: normal
versions: + Python 2.7
nosy: + flox

messages: + msg97585

stage: needs patch
2010-01-11 09:40:11psdcreate