[issue14015] surrogateescape largely missing from documentation

New submission from Jim Jewett <jimjjewett@gmail.com>: Recent discussion on the mailing lists and in http://bugs.python.org/issue13997 make it clear that the best way to get python2 results for "ASCII-in-the-parts-I-might-process-or-change" is to replace f = open(fname) with f = open(fname, encoding="ascii", errors="surrogateescape") Unfortunately, surrogateescape (let alone this recipe) is not easily discoverable. http://docs.python.org/dev/library/functions.html#open lists 5 error-handlers -- but not this one. It says that other error handlers are possible if they are registered with http://docs.python.org/dev/library/codecs.html#codecs.register_error but I haven't found a way to determine which error handlers are already registered. The codecs.register (as opposed to register_error) documentation does list it as a possible value, but that is the only reference. The other 5 error handlers are also available as module-level functions within the codecs module, and have their own documenation sections within http://docs.python.org/dev/library/codecs.html Neither help(open) nor import codecs; help(codecs) provides any hints of the existence of surrogateescape. Both explicitly suggest that it does not exist, by enumerating other values. ---------- assignee: docs@python components: Documentation, Unicode messages: 153359 nosy: Jim.Jewett, docs@python, ezio.melotti priority: normal severity: normal status: open title: surrogateescape largely missing from documentation versions: Python 3.1, Python 3.2, Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14015> _______________________________________

Changes by Chris Rebert <pybugs@rebertia.com>: ---------- nosy: +cvrebert _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14015> _______________________________________

Changes by Éric Araujo <merwok@netwok.org>: ---------- versions: -Python 3.1 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14015> _______________________________________

Changes by A.M. Kuchling <lists@amk.ca>: ---------- nosy: +akuchling _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14015> _______________________________________

A.M. Kuchling added the comment: Here's a proposed patch that touches the Sphinx documentation and a docstring in codecs.py. The text is slightly revised from my current revisions to the Unicode howto. help(open) says "See the documentation for codecs.register for a list of the permitted encoding error strings". This is strictly correct: the Sphinx documentation features this info. But help(codecs.register) doesn't; it's more helpful to look at help(codecs.Codec). So maybe the docstring for open() should say: "See help(codecs.Codec) for a list of the permitted..." instead. ---------- Added file: http://bugs.python.org/file30514/patch14015.txt _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14015> _______________________________________

Roundup Robot added the comment: New changeset 55f611f55952 by Andrew Kuchling in branch '3.3': Describe 'surrogateescape' in the documentation. http://hg.python.org/cpython/rev/55f611f55952 ---------- nosy: +python-dev resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14015> _______________________________________
participants (5)
-
A.M. Kuchling
-
Chris Rebert
-
Jim Jewett
-
Roundup Robot
-
Éric Araujo