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

alexander.belopolsky python-checkins at python.org
Thu Jan 6 22:57:06 CET 2011


Author: alexander.belopolsky
Date: Thu Jan  6 22:57:06 2011
New Revision: 87811

Log:
Further simplify gettmarg()

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	Thu Jan  6 22:57:06 2011
@@ -131,6 +131,7 @@
         self.assertRaises(OverflowError, time.asctime, (bigyear + 1,) + (0,)*8)
         self.assertRaises(TypeError, time.asctime, 0)
         self.assertRaises(TypeError, time.asctime, ())
+        self.assertRaises(TypeError, time.asctime, (0,) * 10)
 
     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	Thu Jan  6 22:57:06 2011
@@ -297,34 +297,20 @@
 gettmarg(PyObject *args, struct tm *p)
 {
     int y;
-    PyObject *t = NULL;
 
     memset((void *) p, '\0', sizeof(struct tm));
 
-    if (PyTuple_Check(args)) {
-        t = args;
-        Py_INCREF(t);
-    }
-    else {
+    if (!PyTuple_Check(args)) {
         PyErr_SetString(PyExc_TypeError,
                         "Tuple or struct_time argument required");
         return 0;
     }
 
-    if (t == NULL || !PyArg_ParseTuple(t, "iiiiiiiii",
-                                       &y,
-                                       &p->tm_mon,
-                                       &p->tm_mday,
-                                       &p->tm_hour,
-                                       &p->tm_min,
-                                       &p->tm_sec,
-                                       &p->tm_wday,
-                                       &p->tm_yday,
-                                       &p->tm_isdst)) {
-        Py_XDECREF(t);
+    if (!PyArg_ParseTuple(args, "iiiiiiiii",
+                          &y, &p->tm_mon, &p->tm_mday,
+                          &p->tm_hour, &p->tm_min, &p->tm_sec,
+                          &p->tm_wday, &p->tm_yday, &p->tm_isdst))
         return 0;
-    }
-    Py_DECREF(t);
 
     /* XXX: Why 1900?  If the goal is to interpret 2-digit years as those in
      * 20th / 21st century according to the POSIX standard, we can just treat


More information about the Python-checkins mailing list