Make bin() implementation parallel oct() and hex() so that int/long subclasses can override or so that other classes can support.
diff --git a/Objects/intobject.c b/Objects/intobject.c
index f98aee0..5210ee8 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -934,6 +934,12 @@
}
static PyObject *
+int_bin(PyObject *v)
+{
+ return PyNumber_ToBase(v, 2);
+}
+
+static PyObject *
int_oct(PyIntObject *v)
{
return _PyInt_Format(v, 8, 0);
@@ -1231,6 +1237,7 @@
0, /* nb_inplace_floor_divide */
0, /* nb_inplace_true_divide */
(unaryfunc)int_int, /* nb_index */
+ (unaryfunc)int_bin, /* nb_bin */
};
PyTypeObject PyInt_Type = {