mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-133036: Deprecate codecs.open (#133038)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
732d1b0241
commit
4e294f6feb
11 changed files with 58 additions and 37 deletions
|
@ -540,11 +540,19 @@ PyObject * _PyCodec_LookupTextEncoding(const char *encoding,
|
|||
Py_DECREF(attr);
|
||||
if (is_text_codec <= 0) {
|
||||
Py_DECREF(codec);
|
||||
if (!is_text_codec)
|
||||
PyErr_Format(PyExc_LookupError,
|
||||
"'%.400s' is not a text encoding; "
|
||||
"use %s to handle arbitrary codecs",
|
||||
encoding, alternate_command);
|
||||
if (!is_text_codec) {
|
||||
if (alternate_command != NULL) {
|
||||
PyErr_Format(PyExc_LookupError,
|
||||
"'%.400s' is not a text encoding; "
|
||||
"use %s to handle arbitrary codecs",
|
||||
encoding, alternate_command);
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_LookupError,
|
||||
"'%.400s' is not a text encoding",
|
||||
encoding);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue