Fix _PyMethodDef_RawFastCallDict() argument parsing
Issue #29259: * Move also the !PyErr_Occurred() assertion to the top, similar to other functions. * Fix also comment/error messages: the function was renamed to _PyMethodDef_RawFastCallDict()
This commit is contained in:
parent
7612f1e36a
commit
250e4b0063
@ -159,16 +159,16 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg
|
|||||||
PyObject *result;
|
PyObject *result;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
|
/* _PyMethodDef_RawFastCallDict() must not be called with an exception set,
|
||||||
|
because it may clear it (directly or indirectly) and so the
|
||||||
|
caller loses its exception */
|
||||||
|
assert(!PyErr_Occurred());
|
||||||
|
|
||||||
assert(method != NULL);
|
assert(method != NULL);
|
||||||
assert(nargs >= 0);
|
assert(nargs >= 0);
|
||||||
assert(nargs == 0 || args != NULL);
|
assert(nargs == 0 || args != NULL);
|
||||||
assert(kwargs == NULL || PyDict_Check(kwargs));
|
assert(kwargs == NULL || PyDict_Check(kwargs));
|
||||||
|
|
||||||
/* _PyCFunction_FastCallDict() must not be called with an exception set,
|
|
||||||
because it may clear it (directly or indirectly) and so the
|
|
||||||
caller loses its exception */
|
|
||||||
assert(!PyErr_Occurred());
|
|
||||||
|
|
||||||
meth = method->ml_meth;
|
meth = method->ml_meth;
|
||||||
flags = method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
|
flags = method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
|
||||||
|
|
||||||
@ -176,13 +176,14 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg
|
|||||||
{
|
{
|
||||||
case METH_NOARGS:
|
case METH_NOARGS:
|
||||||
if (nargs != 0) {
|
if (nargs != 0) {
|
||||||
goto no_keyword_error;
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"%.200s() takes no arguments (%zd given)",
|
||||||
|
method->ml_name, nargs);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kwargs != NULL && PyDict_GET_SIZE(kwargs) != 0) {
|
if (kwargs != NULL && PyDict_GET_SIZE(kwargs) != 0) {
|
||||||
PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
|
goto no_keyword_error;
|
||||||
method->ml_name);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (*meth) (self, NULL);
|
result = (*meth) (self, NULL);
|
||||||
@ -249,7 +250,7 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
PyErr_SetString(PyExc_SystemError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
"Bad call flags in PyCFunction_Call. "
|
"Bad call flags in _PyMethodDef_RawFastCallDict. "
|
||||||
"METH_OLDARGS is no longer supported!");
|
"METH_OLDARGS is no longer supported!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -258,8 +259,9 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg
|
|||||||
|
|
||||||
no_keyword_error:
|
no_keyword_error:
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"%.200s() takes no arguments (%zd given)",
|
"%.200s() takes no keyword arguments",
|
||||||
method->ml_name, nargs);
|
method->ml_name, nargs);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user