]> granicus.if.org Git - python/commitdiff
Keep the list.pop() optimization while restoring the many possibility
authorRaymond Hettinger <python@rcn.com>
Thu, 19 Feb 2004 06:12:06 +0000 (06:12 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 19 Feb 2004 06:12:06 +0000 (06:12 +0000)
for types other than PyInt being accepted for the optional argument.
(Spotted by Neal Norwitz.)

Objects/listobject.c

index 7289be1286fdd47d2cc7f901edf727573844a2ff..162efa0ce3f405a66e89f84ceeab8d910430a7ee 100644 (file)
@@ -779,10 +779,8 @@ listpop(PyListObject *self, PyObject *args)
        if (arg != NULL) {
                if (PyInt_Check(arg))
                        i = (int)(PyInt_AS_LONG((PyIntObject*) arg));
-               else {
-                       PyErr_SetString(PyExc_TypeError, "an integer is required");
-                       return NULL;
-               }
+               else if (!PyArg_ParseTuple(args, "|i:pop", &i))
+                       return NULL;
        }
        if (self->ob_size == 0) {
                /* Special-case most common failure cause */