]> granicus.if.org Git - python/commitdiff
Issue #27809: tzinfo_reduce() uses fast call
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Aug 2016 22:11:04 +0000 (00:11 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Aug 2016 22:11:04 +0000 (00:11 +0200)
Modules/_datetimemodule.c

index a62f5929578d7ea4853545e4d5643b0a8d175875..7e95af749719d052f1bc35ca0bc903c274ee6d9f 100644 (file)
@@ -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);