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-119189: Fix the fraction module so that __rpow__ works on arbitrary classes. by zitterbewegung · Pull Request #119242 · python/cpython

Conversation

@zitterbewegung

@zitterbewegung zitterbewegung commented May 20, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

gh-119189: Fix the fraction module so that rpow works on arbitrary classes.

 The fraction module implicitly casted float if __rpow__ was implemented in your class when raising a fraction to a power. Now we replace the cast to float and instead check if it is a float or complex  and if the class isn't it will raise an exception.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added the awaiting review label May 20, 2024
@zitterbewegung zitterbewegung changed the title Fix the fraction module so that __rpow__ works on arbitrary classes. gh-119189: Fix the fraction module so that __rpow__ works on arbitrary classes. May 20, 2024
@bedevere-app bedevere-app Bot mentioned this pull request May 20, 2024
Fraction wrongfully gets casted into float when given as argument to __rpow__ #119189
Closed
@zitterbewegung
Fix the fraction module so that __rpow__ works on arbitrary classes.
1de7a44
The fraction module implicitly casted float if __rpow__ was implemented in your class when raising a fraction to a power. Now it isn't done but will raise an exception if __rpow__ isn't implemented.
@zitterbewegung
zitterbewegung force-pushed the fix-issue-119189 branch from 7d628e3 to 1de7a44 Compare May 20, 2024 20:02
@zitterbewegung
Merge branch 'python:main' into fix-issue-119189
a13f31e
serhiy-storchaka
serhiy-storchaka approved these changes May 21, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

Please update tests.

Also, I think that the text of the NEWS entry should be rewritten. It's hard to understand right now, I'm not even sure if it's correct at all.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 21, 2024
@zitterbewegung
Merge branch 'main' into fix-issue-119189
2becad7
serhiy-storchaka
serhiy-storchaka requested changes May 22, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

Please update tests and rewrite the NEWS entry.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot removed the awaiting merge label May 22, 2024
@bedevere-app

bedevere-app Bot commented May 22, 2024

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added the awaiting changes label May 22, 2024
@zitterbewegung

zitterbewegung commented May 25, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

Okay I will update tests.

All reactions

Sorry, something went wrong.

Uh oh!

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

zitterbewegung added 2 commits May 25, 2024 15:45
@zitterbewegung
Merge branch 'main' into fix-issue-119189
07cd7d1
@zitterbewegung
Update 2024-05-20-13-48-37.gh-issue-119189.dhJVs5.rst
62e654f
@zitterbewegung

zitterbewegung commented May 28, 2024

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels May 28, 2024
@bedevere-app

bedevere-app Bot commented May 28, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

@serhiy-storchaka: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app
bedevere-app Bot requested a review from serhiy-storchaka May 28, 2024 12:20
@serhiy-storchaka

serhiy-storchaka commented May 28, 2024

Copy link
Copy Markdown
Member

Tests are still failing. You have to make them pass.

All reactions

Sorry, something went wrong.

Uh oh!

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

zitterbewegung added 4 commits May 28, 2024 08:26
@zitterbewegung
Merge branch 'python:main' into fix-issue-119189
80dee37
@zitterbewegung
Adding passing tests
1265604
@zitterbewegung
Merge branch 'python:main' into fix-issue-119189
ad77ebe
@zitterbewegung
Merge branch 'main' into fix-issue-119189
29cd6b3
@zitterbewegung

zitterbewegung commented May 29, 2024

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app

bedevere-app Bot commented May 29, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

@serhiy-storchaka: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka
serhiy-storchaka reviewed May 29, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2024-05-20-13-48-37.gh-issue-119189.dhJVs5.rst Resolved

Uh oh!

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

Comment thread Lib/test/test_fractions.py Resolved

Uh oh!

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

zitterbewegung and others added 4 commits May 29, 2024 12:54
@zitterbewegung
Merge branch 'python:main' into fix-issue-119189
267b2f2
@zitterbewegung @serhiy-storchaka
Update 2024-05-20-13-48-37.gh-issue-119189.dhJVs5.rst
085a9d1
Co-authored-by: Serhiy Storchaka <[email protected]>
@zitterbewegung
Merge branch 'python:main' into fix-issue-119189
d652c0d
@zitterbewegung
Update test_fractions.py
b585219
Added accidental removal of comment
@zitterbewegung

zitterbewegung commented May 30, 2024

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app

bedevere-app Bot commented May 30, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

@serhiy-storchaka: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app
bedevere-app Bot requested a review from serhiy-storchaka May 30, 2024 00:28
serhiy-storchaka
serhiy-storchaka approved these changes May 30, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

LGTM. Thank you for your contribution @zitterbewegung.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels May 30, 2024
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) May 30, 2024 10:30
@serhiy-storchaka
Merge branch 'main' into fix-issue-119189
82100b1
@serhiy-storchaka
serhiy-storchaka merged commit b9965ef into python:main May 31, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label May 31, 2024
@serhiy-storchaka serhiy-storchaka added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels May 31, 2024
@miss-islington-app

miss-islington-app Bot commented May 31, 2024

Copy link
Copy Markdown

Thanks @zitterbewegung for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington-app

miss-islington-app Bot commented May 31, 2024

Copy link
Copy Markdown

Thanks @zitterbewegung for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 31, 2024
@zitterbewegung @miss-islington
pythongh-119189: Fix the power operator for Fraction (pythonGH-119242)
490062a
When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
(cherry picked from commit b9965ef)

Co-authored-by: Joshua Herman <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 31, 2024
@zitterbewegung @miss-islington
pythongh-119189: Fix the power operator for Fraction (pythonGH-119242)
e895b00
When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
(cherry picked from commit b9965ef)

Co-authored-by: Joshua Herman <[email protected]>
@bedevere-app

bedevere-app Bot commented May 31, 2024

Copy link
Copy Markdown

GH-119835 is a backport of this pull request to the 3.12 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.12 only security fixes label May 31, 2024
@bedevere-app

bedevere-app Bot commented May 31, 2024

Copy link
Copy Markdown

GH-119836 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 May 31, 2024
@serhiy-storchaka

serhiy-storchaka commented May 31, 2024

Copy link
Copy Markdown
Member

I consider this a bug fix.

All reactions

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka pushed a commit that referenced this pull request Jul 16, 2024
@miss-islington @zitterbewegung
[3.12] gh-119189: Fix the power operator for Fraction (GH-119242) (GH…
d4f57cc
…-119835)

When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
(cherry picked from commit b9965ef)

Co-authored-by: Joshua Herman <[email protected]>
serhiy-storchaka pushed a commit that referenced this pull request Jul 16, 2024
@miss-islington @zitterbewegung
[3.13] gh-119189: Fix the power operator for Fraction (GH-119242) (GH…
d02adec
…-119836)

When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
(cherry picked from commit b9965ef)

Co-authored-by: Joshua Herman <[email protected]>
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@zitterbewegung @estyxx
pythongh-119189: Fix the power operator for Fraction (pythonGH-119242)
5e16e85
When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
scoder added a commit to scoder/quicktions that referenced this pull request Nov 28, 2024
@scoder
Fix the power operator for non float/complex values.
509036c
See python/cpython#119242
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes

Uh oh!

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

Assignees

No one assigned

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.

2 participants

@zitterbewegung @serhiy-storchaka
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.