mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +00:00
Make bin() implementation parallel oct() and hex() so that int/long subclasses can override or so that other classes can support.
This commit is contained in:
parent
e0f124495b
commit
e3ae655edf
7 changed files with 49 additions and 2 deletions
|
@ -3300,6 +3300,12 @@ long_float(PyObject *v)
|
|||
return PyFloat_FromDouble(result);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
long_bin(PyObject *v)
|
||||
{
|
||||
return PyNumber_ToBase(v, 2);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
long_oct(PyObject *v)
|
||||
{
|
||||
|
@ -3540,6 +3546,7 @@ static PyNumberMethods long_as_number = {
|
|||
0, /* nb_inplace_floor_divide */
|
||||
0, /* nb_inplace_true_divide */
|
||||
long_long, /* nb_index */
|
||||
long_bin, /* nb_bin */
|
||||
};
|
||||
|
||||
PyTypeObject PyLong_Type = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue