-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
int.__round__(None)
is not supported
#120080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I do not think that there is a bug. The operation that works on a float and on an int is |
… ``int.__round__`` (#120088) Co-authored-by: Nikita Sobolev <[email protected]>
…of the ``int.__round__`` (pythonGH-120088) (cherry picked from commit 57ad769) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Nikita Sobolev <[email protected]>
Fixed by commit: 57ad769. See my rationale for the change: #120088 (comment). |
Note that Not everything that can be implemented should be implemented, and I believe that this is such a case. |
My motivation to merge the PR was to avoid |
#73536 is the general solution of this problem. |
Ok, but this issue is open since 2017 and is not fixed yet. IMO accepting None is just a harmless way to fix the issue. |
Few months ago I finally created a draft (#117671). I hope this will be included in 3.14. |
…of the ``int.__round__`` (python#120088) Co-authored-by: Nikita Sobolev <[email protected]>
…of the ``int.__round__`` (python#120088) Co-authored-by: Nikita Sobolev <[email protected]>
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
None
as a valid argument for direct call of theint.__round__
#120088None
as a valid argument for direct call of theint.__round__
(GH-120088) #120197test_round_with_none_arg_direct_call
ascpython_only
#120328The text was updated successfully, but these errors were encountered: