GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-120080: Accept ``None`` as a valid argument for direct call of the ``int.__round__`` by Eclips4 · Pull Request #120088 · python/cpython

Conversation

@Eclips4

@Eclips4 Eclips4 commented Jun 5, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: int.__round__(None) is not supported #120080

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

CharlieZhao95 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Eclips4 added 3 commits June 5, 2024 08:37
@Eclips4
Accept None in int.__round__
9b63403
@Eclips4
Add a NEWS entry
b6a64ef
@Eclips4
Add a test cases
6cc13fa
@Eclips4
Eclips4 requested a review from JelleZijlstra June 5, 2024 05:50
@bedevere-app bedevere-app Bot added the awaiting review label Jun 5, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Jun 5, 2024
int.__round__(None) is not supported #120080
Closed
@Eclips4 Eclips4 added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Jun 5, 2024
Eclips4 added 4 commits June 5, 2024 08:52
@Eclips4
Add a missing newline
6aa8ded
@Eclips4
Change clinic annotation and remove unecessary check
d000960
@Eclips4
forgot to commit this..
59e859c
@Eclips4
Update test_inspect.py
4d01917
sobolevn
sobolevn reviewed Jun 5, 2024
View reviewed changes
Comment thread Lib/test/test_int.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

sobolevn
sobolevn reviewed Jun 5, 2024
View reviewed changes
Comment thread Lib/test/test_float.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Eclips4 and others added 3 commits June 5, 2024 11:19
@Eclips4 @sobolevn
Update Lib/test/test_float.py
46a7692
Co-authored-by: Nikita Sobolev <[email protected]>
@Eclips4
Fix indent
dde13ea
@Eclips4
Update Lib/test/test_int.py
e1e4999
sobolevn
sobolevn reviewed Jun 5, 2024
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_int.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Eclips4 @sobolevn
Update Lib/test/test_int.py
bd80248
Co-authored-by: Nikita Sobolev <[email protected]>
sobolevn
sobolevn approved these changes Jun 5, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Jun 5, 2024
@Eclips4

Eclips4 commented Jun 5, 2024

Copy link
Copy Markdown
Member Author

Thanks for the review, Nikita!

sobolevn reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit 57ad769 into python:main Jun 7, 2024
@miss-islington-app

miss-islington-app Bot commented Jun 7, 2024

Copy link
Copy Markdown

Thanks @Eclips4 for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Jun 7, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 7, 2024
@Eclips4 @sobolevn @miss-islington
pythongh-120080: Accept None as a valid argument for direct call …
4e3866e
…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]>
@miss-islington-app

miss-islington-app Bot commented Jun 7, 2024

Copy link
Copy Markdown

Sorry, @Eclips4 and @vstinner, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 57ad769076201c858a768d81047f6ea44925a33b 3.12
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Jun 7, 2024

Copy link
Copy Markdown

GH-120197 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jun 7, 2024
@miss-islington-app miss-islington-app Bot assigned vstinner Jun 7, 2024
@vstinner vstinner removed the needs backport to 3.12 only security fixes label Jun 7, 2024
@vstinner

vstinner commented Jun 7, 2024

Copy link
Copy Markdown
Member

I merged the change. Thanks @Eclips4!

I don't think that such change deserves to be backported. It's a minor issue.

While @serhiy-storchaka disagrees with the change: #120080 (comment), IMO it makes the code more consistent. With this change, round(), float.__round__() and int.__round__() accept None for ndigits. It also makes help(nt.__round__) nicer. If tomorrow, we decide to reject None, it should be consistent and be rejected in the 3 ways to call "round". But I don't think that we want to reject None, it's convenient and works currently.

Note: I would prefer to have 0 as the default value rather than None. But well, it's too change to change such detail :-)

Internally, round(obj, None) calls obj.__round__() (0 arguments), whereas round(obj, ndigits) calls obj.__round__(ndigits) (1 argument).

Eclips4 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Eclips4
Eclips4 deleted the issue-120080 branch June 7, 2024 08:14
@serhiy-storchaka

serhiy-storchaka commented Jun 7, 2024

Copy link
Copy Markdown
Member

float.__round__() needs to distinguish 0 from no argument. Accepting None is just an implementation detail. I do not think we should add tests for this, because now this becomes a self-official feature.

int.__round__() could have 0 as the default, this would simplify the code.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 7, 2024

Copy link
Copy Markdown
Member

I do not think we should add tests for this, because now this becomes a self-official feature.

The tests can be decorated with @support.cpython_only.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Eclips4 Eclips4 mentioned this pull request Jun 10, 2024
gh-120080: Mark test_round_with_none_arg_direct_call as cpython_only #120328
Merged
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@Eclips4 @sobolevn @estyxx
pythongh-120080: Accept None as a valid argument for direct call …
86ce3ff
…of the ``int.__round__`` (python#120088)

Co-authored-by: Nikita Sobolev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sobolevn sobolevn sobolevn approved these changes
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@vstinner vstinner

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Eclips4 @vstinner @serhiy-storchaka @sobolevn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.