summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-07-25 21:59:48 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-07-25 21:59:48 (GMT)
commit5a2146a2fdb9b8adf6472f1bedbba68c41bab232 (patch)
tree0617249197e601d5cf56f982c78234593d54b46d /Modules
parent65dd69a3da16257bd86b92900e5ec5a8dd26f1d9 (diff)
downloadcpython-5a2146a2fdb9b8adf6472f1bedbba68c41bab232.zip
cpython-5a2146a2fdb9b8adf6472f1bedbba68c41bab232.tar.gz
cpython-5a2146a2fdb9b8adf6472f1bedbba68c41bab232.tar.bz2
Issue #22044: Fixed premature DECREF in call_tzinfo_method.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_datetimemodule.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 496ff34..d8225ba 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -897,11 +897,11 @@ call_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg)
}
}
else {
- Py_DECREF(offset);
PyErr_Format(PyExc_TypeError,
"tzinfo.%s() must return None or "
"timedelta, not '%.200s'",
name, Py_TYPE(offset)->tp_name);
+ Py_DECREF(offset);
return NULL;
}
@@ -2153,7 +2153,7 @@ delta_new(PyTypeObject *type, PyObject *args, PyObject *kw)
* is odd. Note that x is odd when it's last bit is 1. The
* code below uses bitwise and operation to check the last
* bit. */
- temp = PyNumber_And(x, one); /* temp <- x & 1 */
+ temp = PyNumber_And(x, one); /* temp <- x & 1 */
if (temp == NULL) {
Py_DECREF(x);
goto Done;
@@ -3224,10 +3224,10 @@ timezone_richcompare(PyDateTime_TimeZone *self,
if (op != Py_EQ && op != Py_NE)
Py_RETURN_NOTIMPLEMENTED;
if (Py_TYPE(other) != &PyDateTime_TimeZoneType) {
- if (op == Py_EQ)
- Py_RETURN_FALSE;
- else
- Py_RETURN_TRUE;
+ if (op == Py_EQ)
+ Py_RETURN_FALSE;
+ else
+ Py_RETURN_TRUE;
}
return delta_richcompare(self->offset, other->offset, op);
}
@@ -4814,7 +4814,7 @@ datetime_astimezone(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
static char *keywords[] = {"tz", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kw, "|O:astimezone", keywords,
- &tzinfo))
+ &tzinfo))
return NULL;
if (check_tzinfo_subclass(tzinfo) == -1)