diff options
author | Inada Naoki <songofacandy@gmail.com> | 2025-04-30 01:11:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-30 01:11:09 (GMT) |
commit | 4e294f6feb3193854d23e0e8be487213a80b232f (patch) | |
tree | 5bd03678ff6136ef2a7ffb03a088388c275713c7 /Python/codecs.c | |
parent | 732d1b02417e91d6a4247879e290065287cc6b51 (diff) | |
download | cpython-4e294f6feb3193854d23e0e8be487213a80b232f.zip cpython-4e294f6feb3193854d23e0e8be487213a80b232f.tar.gz cpython-4e294f6feb3193854d23e0e8be487213a80b232f.tar.bz2 |
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>
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 265f521..caf8d9d 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -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; } } |