As per Armin Rigo's suggestion, remove special handing from intobject.c to deal with the peculiarities of classobject's implementation of the number protocol. The nb_long method of classobject now falls back to nb_int if there is no __long__ attribute present.
diff --git a/Objects/intobject.c b/Objects/intobject.c
index a82b3c8..9333a55 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -213,15 +213,10 @@
return -1;
}
- if (nb->nb_long != 0) {
+ if (nb->nb_long != 0)
io = (PyIntObject*) (*nb->nb_long) (op);
- if (io == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- io = (PyIntObject*) (*nb->nb_int) (op);
- }
- } else {
+ else
io = (PyIntObject*) (*nb->nb_int) (op);
- }
if (io == NULL)
return -1;
if (!PyInt_Check(io)) {