diff options
-rw-r--r-- | Python/bltinmodule.c | 6 |
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[] = |