Skip to content

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

Merged
vstinner merged 7 commits into
python:mainfrom
skirpichev:fix-legacy-repr-tests
Jun 27, 2025
Merged

gh-128051: fix tests if sys.float_repr_style is 'legacy'#135908
vstinner merged 7 commits into
python:mainfrom
skirpichev:fix-legacy-repr-tests

Conversation

@skirpichev

@skirpichev skirpichev commented Jun 25, 2025

Copy link
Copy Markdown
Member

@skirpichev

Copy link
Copy Markdown
Member Author

CC @vstinner

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

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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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.

Copy link
Copy Markdown
Member 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.

Comment thread Lib/test/test_builtin.py Outdated
@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
Copy Markdown
Member

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

Comment thread Lib/test/test_enum.py Outdated
Comment thread Lib/test/test_float.py Outdated
Comment thread Lib/test/test_statistics.py Outdated
Comment thread Lib/test/test_ctypes/test_parameters.py Outdated
WorseStruct().__setstate__({}, b'foo')

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

Copy link
Copy Markdown
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.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown

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
Copy Markdown

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

bedevere-app Bot commented Jun 27, 2025

Copy link
Copy Markdown

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

bedevere-app Bot commented Jun 27, 2025

Copy link
Copy Markdown

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
vstinner added a commit that referenced this pull request Jun 30, 2025
) (#136026)

gh-128051: Fix tests if sys.float_repr_style is 'legacy' (#135908)


(cherry picked from commit f3aec60)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
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