mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-33073: Rework int.as_integer_ratio() implementation (GH-9303)
* Simplify the C code. * Simplify tests and make them more strict and robust. * Add references in the documentation.
This commit is contained in:
parent
b981fec8d6
commit
b2e2025941
3 changed files with 9 additions and 36 deletions
|
@ -5280,13 +5280,8 @@ static PyObject *
|
|||
int_as_integer_ratio_impl(PyObject *self)
|
||||
/*[clinic end generated code: output=e60803ae1cc8621a input=55ce3058e15de393]*/
|
||||
{
|
||||
PyObject *numerator;
|
||||
PyObject *ratio_tuple;
|
||||
|
||||
if (PyLong_CheckExact(self)) {
|
||||
return PyTuple_Pack(2, self, _PyLong_One);
|
||||
}
|
||||
numerator = _PyLong_Copy((PyLongObject *) self);
|
||||
PyObject *numerator = long_long(self);
|
||||
if (numerator == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue