diff Objects/listobject.c @ 31550:bdf006dee698 legacy-trunk

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.)
author Raymond Hettinger <python@rcn.com>
date Thu, 19 Feb 2004 06:12:06 +0000
parents 72e970c0accc
children 635eebc473b0
line wrap: on
line diff
--- a/Objects/listobject.c	Thu Feb 19 02:44:22 2004 +0000
+++ b/Objects/listobject.c	Thu Feb 19 06:12:06 2004 +0000
@@ -779,10 +779,8 @@
 	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 */