codecs.encode
with utf-*
encoding and errors returing str
rejects surrogates blindly
#127305
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
stdlib
Python modules in the Lib dir
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
For
codecs.encode
,with
utf-*
encoding, and a customerrors
which returnsstr
,if you pass some characters that are not invalid UTF characters (e.g. surrogates),
UnicodeEncodeError
is just raised and there's not the expected (and documented) casewhere the returned
str
is appended.Output:
CPython versions tested on:
3.9, 3.11, 3.12, 3.13, 3.14
Operating systems tested on:
Linux, Windows
The text was updated successfully, but these errors were encountered: