diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-16 14:18:57 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-16 14:18:57 (GMT) |
commit | 5ab81d787f455ba28367b5b71606cea376283574 (patch) | |
tree | e78623a175940cb3d25d950812d0079021b178b7 /Modules/_operator.c | |
parent | 1d59a0aacf1ddd000b6c6e231cf82ddf74afe3b4 (diff) | |
download | cpython-5ab81d787f455ba28367b5b71606cea376283574.zip cpython-5ab81d787f455ba28367b5b71606cea376283574.tar.gz cpython-5ab81d787f455ba28367b5b71606cea376283574.tar.bz2 |
Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of dict.
Diffstat (limited to 'Modules/_operator.c')
-rw-r--r-- | Modules/_operator.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/Modules/_operator.c b/Modules/_operator.c index fb8eafc..f5b8612 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -1016,16 +1016,7 @@ methodcaller_repr(methodcallerobject *mc) return PyUnicode_FromFormat("%s(...)", Py_TYPE(mc)->tp_name); } - if (mc->kwds != NULL) { - numkwdargs = PyDict_Size(mc->kwds); - if (numkwdargs < 0) { - Py_ReprLeave((PyObject *)mc); - return NULL; - } - } else { - numkwdargs = 0; - } - + numkwdargs = mc->kwds != NULL ? PyDict_GET_SIZE(mc->kwds) : 0; numposargs = PyTuple_GET_SIZE(mc->args); numtotalargs = numposargs + numkwdargs; @@ -1092,7 +1083,7 @@ static PyObject * methodcaller_reduce(methodcallerobject *mc) { PyObject *newargs; - if (!mc->kwds || PyDict_Size(mc->kwds) == 0) { + if (!mc->kwds || PyDict_GET_SIZE(mc->kwds) == 0) { Py_ssize_t i; Py_ssize_t callargcount = PyTuple_GET_SIZE(mc->args); newargs = PyTuple_New(1 + callargcount); |