summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-06-29 22:26:50 (GMT)
committerGuido van Rossum <guido@python.org>1998-06-29 22:26:50 (GMT)
commit8ea9f4d10aa81251aa857362e9e3fb17511d99db (patch)
tree193925bd70974d60ffd4b87ac94b752da85ea458
parent16926bd75e6292e7096d3bb8bd47a007823ef85a (diff)
downloadcpython-8ea9f4d10aa81251aa857362e9e3fb17511d99db.zip
cpython-8ea9f4d10aa81251aa857362e9e3fb17511d99db.tar.gz
cpython-8ea9f4d10aa81251aa857362e9e3fb17511d99db.tar.bz2
Fix a stupid little bug: len() of an unsized returns -1 and leaves an
exception waiting to happen next...
-rw-r--r--Python/bltinmodule.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 727f8d1..775c318 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1098,10 +1098,14 @@ builtin_len(self, args)
PyObject *args;
{
PyObject *v;
+ long res;
if (!PyArg_ParseTuple(args, "O:len", &v))
return NULL;
- return PyInt_FromLong((long)PyObject_Length(v));
+ res = PyObject_Length(v);
+ if (res < 0 && PyErr_Occurred())
+ return NULL;
+ return PyInt_FromLong(res);
}
static char len_doc[] =