diff options
author | Raymond Hettinger <python@rcn.com> | 2009-02-03 02:12:10 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-02-03 02:12:10 +0000 |
commit | 8895a32b6e054eaacea00957be4cdcb127c73920 (patch) | |
tree | 9a226eeef63cd2507b4582304d6a87984204bce1 /Objects/abstract.c | |
parent | 10c295dcc0310c0c843dc9957bbec7d01cb1119c (diff) | |
download | cpython-8895a32b6e054eaacea00957be4cdcb127c73920.tar.gz |
Validate that __length_hint__ returns a usable result.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r-- | Objects/abstract.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 86e2c39480..7d0ed06117 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -105,7 +105,7 @@ _PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue) PyErr_Clear(); return defaultvalue; } - rv = PyLong_AsSsize_t(ro); + rv = PyLong_Check(ro) ? PyLong_AsSsize_t(ro) : defaultvalue; Py_DECREF(ro); return rv; } |