mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),
PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly.
This commit is contained in:
parent
50451eb912
commit
fa494fd883
10 changed files with 83 additions and 36 deletions
|
@ -549,12 +549,13 @@ PyObject * _PyCodec_LookupTextEncoding(const char *encoding,
|
|||
} else {
|
||||
is_text_codec = PyObject_IsTrue(attr);
|
||||
Py_DECREF(attr);
|
||||
if (!is_text_codec) {
|
||||
if (is_text_codec <= 0) {
|
||||
Py_DECREF(codec);
|
||||
PyErr_Format(PyExc_LookupError,
|
||||
"'%.400s' is not a text encoding; "
|
||||
"use %s to handle arbitrary codecs",
|
||||
encoding, alternate_command);
|
||||
if (!is_text_codec)
|
||||
PyErr_Format(PyExc_LookupError,
|
||||
"'%.400s' is not a text encoding; "
|
||||
"use %s to handle arbitrary codecs",
|
||||
encoding, alternate_command);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue