8000 gh-132876: workaround broken ldexp() on Windows 10 by skirpichev · Pull Request #133135 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-132876: workaround broken ldexp() on Windows 10 #133135

8000
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

Merged
merged 10 commits into from
May 26, 2025

Conversation

skirpichev
Copy link
Contributor
@skirpichev skirpichev commented Apr 29, 2025

ldexp() on Windows doesn't round subnormal results before Windows 11, but should. Python's :func:math.ldexp wrapper now does round them.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
@skirpichev
Copy link
Contributor Author

Some benchmarking in: #132876 (comment)

@skirpichev skirpichev requested a review from tim-one April 29, 2025 18:26
Copy link
Member
@tim-one tim-one left a comment

Choose a reason for hiding this comment

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

Since this is a potentially breaking change on Windows, it really needs a NEWS entry, yes? Like

math.ldexp() on Windows failed to round subnormal results before Window 11, and Microsoft probably won't fix it for Windows 10. So Python works around the error on Windows now. This may change results (which were formerly erroneous) in rare cases.

And maybe link to the issue report?

@zooba
Copy link
Member
zooba commented Apr 29, 2025

It has a NEWS entry, though it could include a bit more detail (such as the ranges of values that may be incorrect). And that entry will already be linked to the bug. So this change LGTM

@skirpichev skirpichev requested a review from zooba April 30, 2025 07:27
@skirpichev skirpichev added the needs backport to 3.14 bugs and security fixes label May 7, 2025
@skirpichev skirpichev requested a review from picnixz May 25, 2025 09:46
Copy link
Member
@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Do you want to add a Windows 10-only test maybe? I don't know how easy it would be to detect that we're on W10.

@skirpichev
Copy link
Contributor Author

@picnixz, I just added test unconditionally (though, require IEEE 754).

@tim-one
Copy link
Member
tim-one commented May 26, 2025

@skirpichev, do you need someone else to merge this? I believe all comments have been addressed.

@skirpichev
Copy link
Contributor Author

do you need someone else to merge this?

Yeah, someone with commit bit :-)

@tim-one
Copy link
Member
tim-one commented May 26, 2025

Ah - I didn't realize you don't have that! I'll do it now 😄 ,

@tim-one tim-one merged commit cf8941c into python:main May 26, 2025
39 checks passed
@miss-islington-app
Copy link

Thanks @skirpichev for the PR, and @tim-one for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 26, 2025
…3135)

* pythongh-132876: workaround broken ldexp() on Windows 10

ldexp() fails to round subnormal results before Windows 11,
so hide their bug.
(cherry picked from commit cf8941c)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Tim Peters <tim.peters@gmail.com>
@miss-islington-app
Copy link

Sorry, @skirpichev and @tim-one, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker cf8941c60356acdd00055e5583a2d64761c34af4 3.13

@bedevere-app
Copy link
bedevere-app bot commented May 26, 2025

GH-134684 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label May 26, 2025
@tim-one
Copy link
Member
tim-one commented May 26, 2025

FYI, I'm ignoring the auto-generated backport messages. Partly because I don't understand how that works 😦 .

@skirpichev skirpichev deleted the fix-ldexp-MS/132876 branch May 26, 2025 02:59
@skirpichev
Copy link
Contributor Author
skirpichev commented May 26, 2025

The witch failed to do her job. I'll prepare manual backport for 3.13.

@bedevere-app
Copy link
bedevere-app bot commented May 26, 2025

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

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 26, 2025
tim-one added a commit that referenced this pull request May 26, 2025
…#134684)

gh-132876: workaround broken ldexp() on Windows 10 (GH-133135)

* gh-132876: workaround broken ldexp() on Windows 10

ldexp() fails to round subnormal results before Windows 11,
so hide their bug.
(cherry picked from commit cf8941c)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Tim Peters <tim.peters@gmail.com>
tim-one added a commit that referenced this pull request May 26, 2025
…#134685)

* gh-132876: workaround broken ldexp() on Windows 10

ldexp() fails to round subnormal results before Windows 11,
so hide their bug.
(cherry picked from commit cf8941c)

Co-authored-by: Tim Peters <tim.peters@gmail.com>
@picnixz
Copy link
Member
picnixz commented May 26, 2025

Thanks for merging this Tim! FYI, I never merge something after 8 PM or when I'm not on Linux, just to be sure I can quickly revert if I made a mistake.

@tim-one
Copy link
Member
tim-one commented May 26, 2025

FYI, I'm retired and "8pm" doesn't mean much of anything to me 😉. If I had to stay awake for another 12 hours to repair problems, that would have been OK. This PR was ready to merge for weeks already, passed exhaustive reviews by multiple capable reviewers, and is a straightforward, localized change. While a chance of unforeseen disaster is never absent, it looked as safe as a PR gets 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0