Skip to content

gh-142781: Fix type confusion in zoneinfo weak cache#142925

Merged
encukou merged 9 commits intopython:mainfrom
superboy-zjc:issue-142781
Mar 2, 2026
Merged

gh-142781: Fix type confusion in zoneinfo weak cache#142925
encukou merged 9 commits intopython:mainfrom
superboy-zjc:issue-142781

Conversation

@superboy-zjc
Copy link
Contributor

Validate the types returned from _weak_cache.get() and _weak_cache.setdefault() to prevent type confusion when a ZoneInfo subclass provides a misbehaving cache implementation.

Fixes gh-142781.

Validate the types returned from _weak_cache.get() and
_weak_cache.setdefault() to prevent type confusion when a ZoneInfo
subclass provides a misbehaving cache implementation.
@python-cla-bot
Copy link

python-cla-bot bot commented Dec 18, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Dec 27, 2025

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.

@superboy-zjc superboy-zjc requested a review from picnixz December 29, 2025 06:21
@superboy-zjc
Copy link
Contributor Author

Thanks for the review! I have addressed all the comments above. Ready for another look.

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.

You should update the branch as we ZoneInfo was modified recently.

@superboy-zjc
Copy link
Contributor Author

You should update the branch as we ZoneInfo was modified recently.

Thanks for your advice! All comments are resolved. Let me know if anything else is needed!

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixz picnixz dismissed their stale review January 3, 2026 22:02

changes were addressed

@picnixz picnixz self-requested a review January 3, 2026 22:03
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM. 👍

@StanFromIreland
Copy link
Member

Updating branch to fix the CI, it is currently incompatible.

@StanFromIreland StanFromIreland self-requested a review as a code owner March 1, 2026 10:34
Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

LGTM

@encukou encukou merged commit b611db4 into python:main Mar 2, 2026
47 checks passed
@encukou encukou added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 2, 2026
@miss-islington-app
Copy link

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

@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 2, 2026
…142925)

(cherry picked from commit b611db4)

Co-authored-by: zhong <60600792+superboy-zjc@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 2, 2026
…142925)

(cherry picked from commit b611db4)

Co-authored-by: zhong <60600792+superboy-zjc@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Mar 2, 2026

GH-145418 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 Mar 2, 2026
@bedevere-app
Copy link

bedevere-app bot commented Mar 2, 2026

GH-145419 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 Mar 2, 2026
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.

Type confusion in zoneinfo_ZoneInfo_impl via overridden cache setdefault()

5 participants