mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +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
|
@ -718,12 +718,18 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
"_localdummy_destroyed", (PyCFunction) _localdummy_destroyed, METH_O
|
||||
};
|
||||
|
||||
if (type->tp_init == PyBaseObject_Type.tp_init
|
||||
&& ((args && PyObject_IsTrue(args))
|
||||
|| (kw && PyObject_IsTrue(kw)))) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Initialization arguments are not supported");
|
||||
return NULL;
|
||||
if (type->tp_init == PyBaseObject_Type.tp_init) {
|
||||
int rc = 0;
|
||||
if (args != NULL)
|
||||
rc = PyObject_IsTrue(args);
|
||||
if (rc == 0 && kw != NULL)
|
||||
rc = PyObject_IsTrue(kw);
|
||||
if (rc != 0) {
|
||||
if (rc > 0)
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Initialization arguments are not supported");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
self = (localobject *)type->tp_alloc(type, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue