mirror of
https://github.com/python/cpython.git
synced 2025-09-25 01:43:11 +00:00
When calling a PyCFunction that has METH_KEYWORDS defined, don't
create an empty dictionary if it is called without keyword args. Just pass NULL. XXX I had believed that this caused weird errors, but the test suite runs cleanly.
This commit is contained in:
parent
c898f2cd3b
commit
8af6b83e61
1 changed files with 0 additions and 10 deletions
|
@ -2728,16 +2728,6 @@ call_cfunction(PyObject *func, PyObject *arg, PyObject *kw)
|
||||||
int flags = PyCFunction_GET_FLAGS(func);
|
int flags = PyCFunction_GET_FLAGS(func);
|
||||||
|
|
||||||
if (flags & METH_KEYWORDS) {
|
if (flags & METH_KEYWORDS) {
|
||||||
if (kw == NULL) {
|
|
||||||
static PyObject *dict = NULL;
|
|
||||||
if (dict == NULL) {
|
|
||||||
dict = PyDict_New();
|
|
||||||
if (dict == NULL)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
kw = dict;
|
|
||||||
Py_INCREF(dict);
|
|
||||||
}
|
|
||||||
return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
|
return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
|
||||||
}
|
}
|
||||||
if (kw != NULL && PyDict_Size(kw) != 0) {
|
if (kw != NULL && PyDict_Size(kw) != 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue