Commit 057004c1 authored by Boxiang Sun's avatar Boxiang Sun

check the whether has __long__ function in object, try to call it.

parent f094057e
...@@ -2008,6 +2008,13 @@ extern "C" PyObject* PyNumber_Long(PyObject* o) noexcept { ...@@ -2008,6 +2008,13 @@ extern "C" PyObject* PyNumber_Long(PyObject* o) noexcept {
if (o->cls == int_cls) if (o->cls == int_cls)
return PyLong_FromLong(((BoxedInt*)o)->n); return PyLong_FromLong(((BoxedInt*)o)->n);
PyObject* long_func = PyObject_GetAttrString(o, "__long__");
if (long_func) {
PyObject* long_obj = PyEval_CallObject(long_func, NULL);
Py_DECREF(long_func);
return long_obj;
}
fatalOrError(PyExc_NotImplementedError, "unimplemented"); fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr; return nullptr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment