Fix code example.
Specify that the error handler is used on all relevant APIs.
This commit is contained in:
parent
1d101b9dbc
commit
9f6d250f9f
|
@ -74,7 +74,8 @@ lone half surrogate codes U+DCxx.
|
|||
To convert non-decodable bytes, a new error handler "python-escape" is
|
||||
introduced, which produces these half surrogates. On encoding, the
|
||||
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
|
||||
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")
|
||||
for fn in os.listdir(dirname):
|
||||
# fn is now a str object
|
||||
yield fn.encode(fse, "python-escape"
|
||||
yield fn.encode(fse, "python-escape")
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
|
Loading…
Reference in New Issue