Mercurial > cpython-lru_cache-weakref
diff Objects/typeobject.c @ 47779:edc701d00b62 legacy-trunk
Make bin() implementation parallel oct() and hex() so that int/long subclasses can override or so that other classes can support.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 20 Jun 2008 04:18:15 +0000 |
| parents | 52294af4b663 |
| children | 3ada46f2321d |
line wrap: on
line diff
--- a/Objects/typeobject.c Fri Jun 20 02:47:03 2008 +0000 +++ b/Objects/typeobject.c Fri Jun 20 04:18:15 2008 +0000 @@ -3743,6 +3743,7 @@ if (base->tp_flags & Py_TPFLAGS_HAVE_INDEX) { COPYNUM(nb_index); } + COPYNUM(nb_hex); } if (type->tp_as_sequence != NULL && base->tp_as_sequence != NULL) { @@ -5135,6 +5136,7 @@ SLOT0(slot_nb_int, "__int__") SLOT0(slot_nb_long, "__long__") SLOT0(slot_nb_float, "__float__") +SLOT0(slot_nb_bin, "__bin__") SLOT0(slot_nb_oct, "__oct__") SLOT0(slot_nb_hex, "__hex__") SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O") @@ -5802,6 +5804,8 @@ "long(x)"), UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc, "float(x)"), + UNSLOT("__bin__", nb_bin, slot_nb_bin, wrap_unaryfunc, + "bin(x)"), UNSLOT("__oct__", nb_oct, slot_nb_oct, wrap_unaryfunc, "oct(x)"), UNSLOT("__hex__", nb_hex, slot_nb_hex, wrap_unaryfunc,
