summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-01-12 20:49:19 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-01-12 20:49:19 (GMT)
commite5e298f8755c475e78f8cfc71ee0ea03c6674406 (patch)
treee5d854149357c5207ce32822ff2dee49542eef41 /Objects/abstract.c
parent7c2b66cc02a1c5e3433885640b7d4bd9e0ca5b8a (diff)
downloadcpython-e5e298f8755c475e78f8cfc71ee0ea03c6674406.zip
cpython-e5e298f8755c475e78f8cfc71ee0ea03c6674406.tar.gz
cpython-e5e298f8755c475e78f8cfc71ee0ea03c6674406.tar.bz2
Issue #4910 (1st patch of a series): fix int() and the corresponding
PyNumber_Int/PyNumber_Long API function so that it no longer attempts to call the __long__ method for conversion. Only the __int__ and __trunc__ methods are used. (This removes a major remaining use of the nb_long slot from the Python 3.x core.) Thanks Benjamin for review.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index aee20d6..0a0333c 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1379,19 +1379,7 @@ PyNumber_Long(PyObject *o)
}
return res;
}
- if (m && m->nb_long) { /* This should include subclasses of long */
- /* Classic classes always take this branch. */
- PyObject *res = m->nb_long(o);
- if (res && !PyLong_Check(res)) {
- PyErr_Format(PyExc_TypeError,
- "__long__ returned non-long (type %.200s)",
- res->ob_type->tp_name);
- Py_DECREF(res);
- return NULL;
- }
- return res;
- }
- if (PyLong_Check(o)) /* A long subclass without nb_long */
+ if (PyLong_Check(o)) /* An int subclass without nb_int */
return _PyLong_Copy((PyLongObject *)o);
trunc_func = PyObject_GetAttr(o, trunc_name);
if (trunc_func) {