[Python-checkins] r87648 - in python/branches/py3k: Lib/test/test_time.py Modules/timemodule.c

alexander.belopolsky python-checkins at python.org
Sun Jan 2 21:48:22 CET 2011


Author: alexander.belopolsky
Date: Sun Jan 2 21:48:22 2011
New Revision: 87648
Log:
Issue #8013: Fixed time.asctime segfault when OS's asctime fails
Modified:
 python/branches/py3k/Lib/test/test_time.py
 python/branches/py3k/Modules/timemodule.c
Modified: python/branches/py3k/Lib/test/test_time.py
==============================================================================
--- python/branches/py3k/Lib/test/test_time.py	(original)
+++ python/branches/py3k/Lib/test/test_time.py	Sun Jan 2 21:48:22 2011
@@ -122,6 +122,9 @@
 def test_asctime(self):
 time.asctime(time.gmtime(self.t))
 self.assertRaises(TypeError, time.asctime, 0)
+ self.assertRaises(TypeError, time.asctime, ())
+ self.assertRaises(ValueError, time.asctime,
+ (12345, 1, 0, 0, 0, 0, 0, 0, 0))
 
 def test_asctime_bounding_check(self):
 self._bounds_checking(time.asctime)
Modified: python/branches/py3k/Modules/timemodule.c
==============================================================================
--- python/branches/py3k/Modules/timemodule.c	(original)
+++ python/branches/py3k/Modules/timemodule.c	Sun Jan 2 21:48:22 2011
@@ -620,6 +620,10 @@
 } else if (!gettmarg(tup, &buf) || !checktm(&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 PyUnicode_FromString(p);


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /