Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-120080: AcceptNone as a valid argument for direct call of theint.__round__#120088

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 11 commits intopython:mainfromEclips4:issue-120080
Jun 7, 2024

Conversation

@Eclips4
Copy link
Member

@Eclips4Eclips4 commentedJun 5, 2024
edited by bedevere-appbot
Loading

CharlieZhao95 reacted with thumbs up emoji
Eclips4and others added3 commitsJune 5, 2024 11:19
Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

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

:)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@Eclips4
Copy link
MemberAuthor

Thanks for the review, Nikita!

sobolevn reacted with heart emoji

@vstinnervstinner merged commit57ad769 intopython:mainJun 7, 2024
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 7, 2024
…of the ``int.__round__`` (pythonGH-120088)(cherry picked from commit57ad769)Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@miss-islington-app
Copy link

Sorry,@Eclips4 and@vstinner, I could not cleanly backport this to3.12 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 57ad769076201c858a768d81047f6ea44925a33b 3.12

@bedevere-app
Copy link

GH-120197 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJun 7, 2024
@vstinner
Copy link
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__() andint.__round__() acceptNone forndigits. It also makeshelp(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 have0 as the default value rather thanNone. But well, it's too change to change such detail :-)

Internally,round(obj, None) callsobj.__round__() (0 arguments), whereasround(obj, ndigits) callsobj.__round__(ndigits) (1 argument).

Eclips4 reacted with thumbs up emoji

@Eclips4Eclips4 deleted the issue-120080 branchJune 7, 2024 08:14
@serhiy-storchaka
Copy link
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.

@vstinner
Copy link
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.

noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
…of the ``int.__round__`` (python#120088)Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
…of the ``int.__round__`` (python#120088)Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@sobolevnsobolevnsobolevn approved these changes

@JelleZijlstraJelleZijlstraAwaiting requested review from JelleZijlstra

Assignees

@vstinnervstinner

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@Eclips4@vstinner@serhiy-storchaka@sobolevn

[8]ページ先頭

©2009-2025 Movatter.jp