[Python-checkins] r87663 - in python/branches/release27-maint: Lib/test/test_time.py Modules/timemodule.c
alexander.belopolsky
python-checkins at python.org
Mon Jan 3 00:23:54 CET 2011
Author: alexander.belopolsky
Date: Mon Jan 3 00:23:54 2011
New Revision: 87663
Log:
Merged revisions 87648,87656 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r87648 | alexander.belopolsky | 2011-01-02 15:48:22 -0500 (Sun, 02 Jan 2011) | 1 line
Issue #8013: Fixed time.asctime segfault when OS's asctime fails
........
r87656 | alexander.belopolsky | 2011-01-02 17:16:10 -0500 (Sun, 02 Jan 2011) | 1 line
Issue #8013: Fixed test
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Lib/test/test_time.py
python/branches/release27-maint/Modules/timemodule.c
Modified: python/branches/release27-maint/Lib/test/test_time.py
==============================================================================
--- python/branches/release27-maint/Lib/test/test_time.py (original)
+++ python/branches/release27-maint/Lib/test/test_time.py Mon Jan 3 00:23:54 2011
@@ -114,6 +114,16 @@
def test_asctime(self):
time.asctime(time.gmtime(self.t))
self.assertRaises(TypeError, time.asctime, 0)
+ self.assertRaises(TypeError, time.asctime, ())
+ # XXX: Posix compiant asctime should refuse to convert
+ # year > 9999, but Linux implementation does not.
+ # self.assertRaises(ValueError, time.asctime,
+ # (12345, 1, 0, 0, 0, 0, 0, 0, 0))
+ # XXX: For now, just make sure we don't have a crash:
+ try:
+ time.asctime((12345, 1, 0, 0, 0, 0, 0, 0, 0))
+ except ValueError:
+ pass
@unittest.skipIf(not hasattr(time, "tzset"),
"time module has no attribute tzset")
Modified: python/branches/release27-maint/Modules/timemodule.c
==============================================================================
--- python/branches/release27-maint/Modules/timemodule.c (original)
+++ python/branches/release27-maint/Modules/timemodule.c Mon Jan 3 00:23:54 2011
@@ -572,6 +572,10 @@
} else if (!gettmarg(tup, &buf))
return NULL;
p = asctime(&buf);
+ if (p == NULL) {
+ PyErr_SetString(PyExc_ValueError, "invalid time");
+ return NULL;
+ }
if (p[24] == '\n')
p[24] = '\0';
return PyString_FromString(p);
More information about the Python-checkins
mailing list