summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-01-08 01:23:02 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-01-08 01:23:02 (GMT)
commit0dd06f4082355451847e686d6adb2f1a9f749adb (patch)
tree87646fee0523846b1e11bf1aab34ecffcaffb883 /Modules/timemodule.c
parentb8bb4664fc8cb833f0fd50c9dac4f6c3be032784 (diff)
downloadcpython-0dd06f4082355451847e686d6adb2f1a9f749adb.zip
cpython-0dd06f4082355451847e686d6adb2f1a9f749adb.tar.gz
cpython-0dd06f4082355451847e686d6adb2f1a9f749adb.tar.bz2
Fixed error handling branches. Thanks
Victor Stinner for pointing this out.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 5732f15..46c90ec 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -332,23 +332,27 @@ gettmarg(PyObject *args, struct tm *p)
if (y < 1000) {
PyObject *accept = PyDict_GetItemString(moddict,
"accept2dyear");
- int acceptval = accept != NULL && PyObject_IsTrue(accept);
- if (acceptval == -1)
- return 0;
- if (acceptval) {
- if (0 <= y && y < 69)
- y += 2000;
- else if (69 <= y && y < 100)
- y += 1900;
- else {
- PyErr_SetString(PyExc_ValueError,
- "year out of range");
+ if (accept != NULL) {
+ int acceptval = PyObject_IsTrue(accept);
+ if (acceptval == -1)
return 0;
+ if (acceptval) {
+ if (0 <= y && y < 69)
+ y += 2000;
+ else if (69 <= y && y < 100)
+ y += 1900;
+ else {
+ PyErr_SetString(PyExc_ValueError,
+ "year out of range");
+ return 0;
+ }
+ if (PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Century info guessed for a 2-digit year.", 1) != 0)
+ return 0;
}
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "Century info guessed for a 2-digit year.", 1) != 0)
- return 0;
}
+ else
+ return 0;
}
p->tm_year = y - 1900;
p->tm_mon--;
@@ -477,6 +481,7 @@ time_strftime(PyObject *self, PyObject *args)
PyErr_Format(PyExc_ValueError, "year=%d is before 1900; "
"the strftime() method requires year >= 1900",
buf.tm_year + 1900);
+ return NULL;
}
/* Normalize tm_isdst just in case someone foolishly implements %Z