summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2005-04-26 03:45:26 (GMT)
committerBrett Cannon <bcannon@gmail.com>2005-04-26 03:45:26 (GMT)
commitc3647ac93e2a38762de8a23b1d94a6380e9ad468 (patch)
treea7e00a7e8f70ee226fdeb3d229b9734d5b17a344 /Objects/longobject.c
parentd7c795e72966f7c72b94b919f3539be66495e6c3 (diff)
downloadcpython-c3647ac93e2a38762de8a23b1d94a6380e9ad468.zip
cpython-c3647ac93e2a38762de8a23b1d94a6380e9ad468.tar.gz
cpython-c3647ac93e2a38762de8a23b1d94a6380e9ad468.tar.bz2
Make subclasses of int, long, complex, float, and unicode perform type
conversion using the proper magic slot (e.g., __int__()). Also move conversion code out of PyNumber_*() functions in the C API into the nb_* function. Applied patch #1109424. Thanks Walter Doewald.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 11a7024..e4fc553 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -2861,7 +2861,10 @@ long_coerce(PyObject **pv, PyObject **pw)
static PyObject *
long_long(PyObject *v)
{
- Py_INCREF(v);
+ if (PyLong_CheckExact(v))
+ Py_INCREF(v);
+ else
+ v = _PyLong_Copy((PyLongObject *)v);
return v;
}