summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-02-19 06:12:06 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-02-19 06:12:06 (GMT)
commitfa6c6f8a73c8da8242c2b4bfb5358733a5f1ef92 (patch)
treea3ade21d52e8e7d2228232bd4a0853739da3ae7c
parent44dbae8cca50ab94acde193df4415a27ac1b47fd (diff)
downloadcpython-fa6c6f8a73c8da8242c2b4bfb5358733a5f1ef92.zip
cpython-fa6c6f8a73c8da8242c2b4bfb5358733a5f1ef92.tar.gz
cpython-fa6c6f8a73c8da8242c2b4bfb5358733a5f1ef92.tar.bz2
Keep the list.pop() optimization while restoring the many possibility
for types other than PyInt being accepted for the optional argument. (Spotted by Neal Norwitz.)
-rw-r--r--Objects/listobject.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 7289be1..162efa0 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -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 */