Skip to content

gh-157892: Fix error check on _Py_hashtable_set() in intern_static() - #157898

Merged
eendebakpt merged 2 commits into
python:mainfrom
rishiraj38:fix/157892-intern-static-hashtable-check
Sep 27, 2026
Merged

eendebakpt merged 2 commits into
python:mainfrom
rishiraj38:fix/157892-intern-static-hashtable-check

Conversation

@rishiraj38

@rishiraj38 rishiraj38 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

_Py_hashtable_set() returns -1 on failure, so the < -1 check in intern_static() was never true and the Py_FatalError() path was unreachable. Check < 0 instead.

No test added, since the failure path is an allocation failure during startup that ends in a fatal error. Built with --with-pydebug and ran test_str, test_sys, test_embed, test_capi.test_unicode and test_unicode_identifiers.

This probably qualifies for skip news.

…tic()

_Py_hashtable_set() returns -1 on failure, so the "< -1" check could
never be true and the Py_FatalError() call was unreachable.
@python-cla-bot

python-cla-bot Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Sep 21, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland

Copy link
Copy Markdown
Member

Please sign the CLA.

@StanFromIreland
StanFromIreland marked this pull request as draft September 21, 2026 15:32
@bedevere-app

bedevere-app Bot commented Sep 22, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@rishiraj38

Copy link
Copy Markdown
Contributor Author

Signed the CLA now, thanks.

@rishiraj38
rishiraj38 marked this pull request as ready for review September 22, 2026 03:53

@eendebakpt eendebakpt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rishiraj38 Thanks!

@rishiraj38

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

@eendebakpt
eendebakpt merged commit a4eb936 into python:main Sep 27, 2026
60 checks passed
@eendebakpt eendebakpt added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Sep 27, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @rishiraj38 for the PR, and @eendebakpt for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @rishiraj38 for the PR, and @eendebakpt for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @rishiraj38 for the PR, and @eendebakpt for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Sep 27, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Sep 27, 2026
@bedevere-app

bedevere-app Bot commented Sep 27, 2026

Copy link
Copy Markdown

GH-158300 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 Sep 27, 2026
@bedevere-app

bedevere-app Bot commented Sep 27, 2026

Copy link
Copy Markdown

GH-158301 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Sep 27, 2026
Yhg1s pushed a commit that referenced this pull request Sep 29, 2026
…atic() (GH-157898) (#158299)

_Py_hashtable_set() returns -1 on failure, so the "< -1" check could never be true and the Py_FatalError() call was unreachable.
(cherry picked from commit a4eb936)

Co-authored-by: Rishi Raj <180109771+rishiraj38@users.noreply.github.com>
eendebakpt added a commit that referenced this pull request Sep 29, 2026
…atic() (GH-157898) (#158300)

gh-157892: Fix error check on _Py_hashtable_set() in intern_static() (GH-157898)

_Py_hashtable_set() returns -1 on failure, so the "< -1" check could never be true and the Py_FatalError() call was unreachable.
(cherry picked from commit a4eb936)

Co-authored-by: Rishi Raj <180109771+rishiraj38@users.noreply.github.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
serhiy-storchaka pushed a commit that referenced this pull request Oct 10, 2026
…atic() (GH-157898) (GH-158301)

_Py_hashtable_set() returns -1 on failure, so the "< -1" check could never be true and the Py_FatalError() call was unreachable.
(cherry picked from commit a4eb936)

Co-authored-by: Rishi Raj <180109771+rishiraj38@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants