From c3647ac93e2a38762de8a23b1d94a6380e9ad468 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 26 Apr 2005 03:45:26 +0000 Subject: 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. --- Objects/longobject.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Objects/longobject.c') diff --git a/Objects/longobject.c b/Objects/longobject.c index 11a7024e45..e4fc553a80 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; } -- cgit v1.2.1