]> granicus.if.org Git - python/commitdiff
Further simplify gettmarg()
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Thu, 6 Jan 2011 21:57:06 +0000 (21:57 +0000)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Thu, 6 Jan 2011 21:57:06 +0000 (21:57 +0000)
Lib/test/test_time.py
Modules/timemodule.c

index af0a960079d4ce84b018e95097c975f02cd4589d..fca221ce9cbb20838ca8b51ad9d9c23e08153a72 100644 (file)
@@ -131,6 +131,7 @@ class TimeTestCase(unittest.TestCase):
         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)
index d73b22bfcccb325054533a622cac78ea6d8a960b..4b45f6e30d360fad3f7b97aef592b3b16007271b 100644 (file)
@@ -297,34 +297,20 @@ static int
 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