Bug report
Bug description:
The __round__ method on floats accepts None as an explicit argument, but the one on int does not:
>>> (1.0).__round__(None)
1
>>> (1).__round__(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object cannot be interpreted as an integer
This goes against the general principle that any operation that works on a float should also work on an int.
(Note that both round(x) and round(x, None) work on both floats and ints; this issue is entirely about direct calls to .__round__().)
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
The
__round__method on floats accepts None as an explicit argument, but the one on int does not:This goes against the general principle that any operation that works on a float should also work on an int.
(Note that both
round(x)andround(x, None)work on both floats and ints; this issue is entirely about direct calls to.__round__().)CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
No response
Linked PRs
Noneas a valid argument for direct call of theint.__round__#120088Noneas a valid argument for direct call of theint.__round__(GH-120088) #120197test_round_with_none_arg_direct_callascpython_only#120328