summaryrefslogtreecommitdiffstats
path: root/Modules/_datetimemodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-22 22:11:04 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-22 22:11:04 (GMT)
commitd1584d3e7e9aeb4d9c9708d0ec5522ab58ae1853 (patch)
treedd6270a71411544ade6f6c1d9bde6082fcc98448 /Modules/_datetimemodule.c
parentf45a56150b029cb7bbe2b928858b12f28f31943c (diff)
downloadcpython-d1584d3e7e9aeb4d9c9708d0ec5522ab58ae1853.zip
cpython-d1584d3e7e9aeb4d9c9708d0ec5522ab58ae1853.tar.gz
cpython-d1584d3e7e9aeb4d9c9708d0ec5522ab58ae1853.tar.bz2
Issue #27809: tzinfo_reduce() uses fast call
Diffstat (limited to 'Modules/_datetimemodule.c')
-rw-r--r--Modules/_datetimemodule.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index a62f592..7e95af7 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -3133,37 +3133,34 @@ Fail:
static PyObject *
tzinfo_reduce(PyObject *self)
{
- PyObject *args, *state, *tmp;
+ PyObject *args, *state;
PyObject *getinitargs, *getstate;
_Py_IDENTIFIER(__getinitargs__);
_Py_IDENTIFIER(__getstate__);
- tmp = PyTuple_New(0);
- if (tmp == NULL)
- return NULL;
-
getinitargs = _PyObject_GetAttrId(self, &PyId___getinitargs__);
if (getinitargs != NULL) {
- args = PyObject_CallObject(getinitargs, tmp);
+ args = _PyObject_CallNoArg(getinitargs);
Py_DECREF(getinitargs);
if (args == NULL) {
- Py_DECREF(tmp);
return NULL;
}
}
else {
PyErr_Clear();
- args = tmp;
- Py_INCREF(args);
+
+ args = PyTuple_New(0);
+ if (args == NULL) {
+ return NULL;
+ }
}
getstate = _PyObject_GetAttrId(self, &PyId___getstate__);
if (getstate != NULL) {
- state = PyObject_CallObject(getstate, tmp);
+ state = _PyObject_CallNoArg(getstate);
Py_DECREF(getstate);
if (state == NULL) {
Py_DECREF(args);
- Py_DECREF(tmp);
return NULL;
}
}
@@ -3172,13 +3169,12 @@ tzinfo_reduce(PyObject *self)
PyErr_Clear();
state = Py_None;
dictptr = _PyObject_GetDictPtr(self);
- if (dictptr && *dictptr && PyDict_Size(*dictptr))
+ if (dictptr && *dictptr && PyDict_Size(*dictptr)) {
state = *dictptr;
+ }
Py_INCREF(state);
}
- Py_DECREF(tmp);
-
if (state == Py_None) {
Py_DECREF(state);
return Py_BuildValue("(ON)", Py_TYPE(self), args);