Alexander Belopolsky <belopol...@users.sourceforge.net> added the comment:
On Tue, Jan 4, 2011 at 1:49 PM, Georg Brandl <rep...@bugs.python.org> wrote:
..
> But if it fails, why not just let it fail?
>
Sure. That's what I meant by fixing the patch. See new patch attached.
----------
Added file: http://bugs.python.org/file20261/issue10827a.diff
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10827>
_______________________________________
Index: Modules/timemodule.c
===================================================================
--- Modules/timemodule.c (revision 87738)
+++ Modules/timemodule.c (working copy)
@@ -355,21 +355,20 @@
if (y < 1900) {
PyObject *accept = PyDict_GetItemString(moddict,
"accept2dyear");
- if (accept == NULL || !PyLong_CheckExact(accept) ||
- !PyObject_IsTrue(accept)) {
- PyErr_SetString(PyExc_ValueError,
- "year >= 1900 required");
+ int acceptval = accept != NULL && PyObject_IsTrue(accept);
+ if (acceptval == -1)
return 0;
+ if (acceptval) {
+ if (69 <= y && y <= 99)
+ y += 1900;
+ else if (0 <= y && y <= 68)
+ y += 2000;
+ else {
+ PyErr_SetString(PyExc_ValueError,
+ "year out of range");
+ return 0;
+ }
}
- if (69 <= y && y <= 99)
- y += 1900;
- else if (0 <= y && y <= 68)
- y += 2000;
- else {
- PyErr_SetString(PyExc_ValueError,
- "year out of range");
- return 0;
- }
}
p->tm_year = y - 1900;
p->tm_mon--;
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com