diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-03-21 03:48:11 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-03-21 03:48:11 (GMT) |
commit | 1b1a8e7cb514d95546af9dcfd42b83cea27182fa (patch) | |
tree | 6383cb08c77cf6f67762301b648ae9ab760cdf28 /Objects/abstract.c | |
parent | 9fc9bf465af96bf753217b0c370e4452882ecd86 (diff) | |
download | cpython-1b1a8e7cb514d95546af9dcfd42b83cea27182fa.zip cpython-1b1a8e7cb514d95546af9dcfd42b83cea27182fa.tar.gz cpython-1b1a8e7cb514d95546af9dcfd42b83cea27182fa.tar.bz2 |
correctly lookup __trunc__ in int() constructor
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r-- | Objects/abstract.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index b8df950..924ccd1 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1350,7 +1350,7 @@ PyNumber_Long(PyObject *o) } if (PyLong_Check(o)) /* An int subclass without nb_int */ return _PyLong_Copy((PyLongObject *)o); - trunc_func = _PyObject_GetAttrId(o, &PyId___trunc__); + trunc_func = _PyObject_LookupSpecial(o, &PyId___trunc__); if (trunc_func) { PyObject *truncated = PyEval_CallObject(trunc_func, NULL); PyObject *int_instance; @@ -1362,7 +1362,8 @@ PyNumber_Long(PyObject *o) "__trunc__ returned non-Integral (type %.200s)"); return int_instance; } - PyErr_Clear(); /* It's not an error if o.__trunc__ doesn't exist. */ + if (PyErr_Occurred()) + return NULL; if (PyBytes_Check(o)) /* need to do extra error checking that PyLong_FromString() |