Closed
Description
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