8000 gh-128051: fix tests if sys.float_repr_style is 'legacy' by skirpichev · Pull Request #135908 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128051: fix tests if sys.float_repr_style is 'legacy' #135908

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 7 commits into from
Jun 27, 2025

Conversation

skirpichev
Copy link
Contributor
@skirpichev skirpichev commented Jun 25, 2025

@skirpichev
Copy link
Contributor Author

CC @vstinner

Second commit contains more controversial changes, i.e. where short and legacy repr - agree (but this tested on IEEE box!)

@@ -240,7 +240,6 @@ def test_parameter_repr(self):
self.assertRegex(repr(c_ulonglong.from_param(20000)), r"^<cparam '[LIQ]' \(20000\)>$")
self.assertEqual(repr(c_float.from_param(1.5)), "<cparam 'f' (1.5)>")
self.assertEqual(repr(c_double.from_param(1.5)), "<cparam 'd' (1.5)>")
self.assertEqual(repr(c_double.from_param(1e300)), "<cparam 'd' (1e+300)>")
Copy link
Member

Choose a reason for hiding this comment

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

Please don't remove tests. Maybe skip it if if getattr(sys, 'float_repr_style', '') == 'short':.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any idea why this was added, given we have other c_double test?

Copy link
Member

Choose a reason for hiding this comment

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

The test was added by commit 916610e.

Sorry, something went wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I know. As well, as other tests in this function, but why? This value fits in double? We have only one test for float/longdouble.

@vstinner vstinner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 25, 2025
@vstinner
Copy link
Member

We usually backport tests changes to stable branches to reduce the risk of merge conflicts for following tests changes.

@@ -224,6 +225,8 @@ def __dict__(self):
with self.assertRaises(ZeroDivisionError):
WorseStruct().__setstate__({}, b'foo')

@unittest.skipUnless(sys.float_repr_style == 'short',
"applies only when using short float repr style")
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to only skip 1e300 test, rather than skipping the whole test method.

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinner vstinner merged commit f3aec60 into python:main Jun 27, 2025
43 checks passed
@miss-islington-app
Copy link

Thanks @skirpichev for the PR, and @vstinner 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 Jun 27, 2025
…nGH-135908)

(cherry picked from commit f3aec60)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
@miss-islington-app
Copy link

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

cherry_picker f3aec60d7a01c5f085a3ef2d6670d46b42b8ddd3 3.13

@bedevere-app
Copy link
bedevere-app bot commented Jun 27, 2025

GH-136025 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 Jun 27, 2025
@bedevere-app
Copy link
bedevere-app bot commented Jun 27, 2025

GH-136026 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 Jun 27, 2025
vstinner added a commit to vstinner/cpython that referenced this pull request Jun 27, 2025
…n#135908)

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit f3aec60)
vstinner added a commit that referenced this pull request Jun 27, 2025
…35908) (#136025)

gh-128051: Fix tests if sys.float_repr_style is 'legacy' (GH-135908)
(cherry picked from commit f3aec60)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
@skirpichev skirpichev deleted the fix-legacy-repr-tests branch June 27, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0