bpo-38631: Replace tp_new_wrapper() fatal error with SystemError (GH-18262)

tp_new_wrapper() now raises a SystemError if called with non-type
self, rather than calling Py_FatalError() which cannot be catched.
This commit is contained in:
Victor Stinner 2020-01-30 09:02:49 +01:00 committed by GitHub
parent 7a1f6c2da4
commit 2bf127d97b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -6042,8 +6042,12 @@ tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
PyTypeObject *type, *subtype, *staticbase;
PyObject *arg0, *res;
if (self == NULL || !PyType_Check(self))
Py_FatalError("__new__() called with non-type 'self'");
if (self == NULL || !PyType_Check(self)) {
PyErr_Format(PyExc_SystemError,
"__new__() called with non-type 'self'");
return NULL;
}
type = (PyTypeObject *)self;
if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) < 1) {
PyErr_Format(PyExc_TypeError,