Fix code example.

Specify that the error handler is used on all relevant APIs.
This commit is contained in:
Martin v. Löwis 2009-04-29 20:06:29 +00:00
parent 1d101b9dbc
commit 9f6d250f9f
1 changed files with 3 additions and 2 deletions

View File

@ -74,7 +74,8 @@ lone half surrogate codes U+DCxx.
To convert non-decodable bytes, a new error handler "python-escape" is To convert non-decodable bytes, a new error handler "python-escape" is
introduced, which produces these half surrogates. On encoding, the introduced, which produces these half surrogates. On encoding, the
error handler converts the half surrogate back to the corresponding error handler converts the half surrogate back to the corresponding
byte. byte. This error handler used used in any API that receives or produces
file names, command line arguments, or environment variables.
The error handler interface is extended to allow the encode error The error handler interface is extended to allow the encode error
handler to return byte strings immediately, in addition to returning handler to return byte strings immediately, in addition to returning
@ -119,7 +120,7 @@ for accepting and returning bytes, would be written as::
dirname = dirname.decode(fse, "python-escape") dirname = dirname.decode(fse, "python-escape")
for fn in os.listdir(dirname): for fn in os.listdir(dirname):
# fn is now a str object # fn is now a str object
yield fn.encode(fse, "python-escape" yield fn.encode(fse, "python-escape")
Copyright Copyright
========= =========