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
encukou pushed a commit that referenced this pull request Mar 3, 2026
… (GH-145418)

(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>
encukou pushed a commit that referenced this pull request Mar 3, 2026
… (GH-145419)

(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-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Debian root 3.13 (tier-1) has failed when building commit dbeb29a.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1441/builds/1812) and take a look at the build logs.
  4. Check if the failure is related to this commit (dbeb29a) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1441/builds/1812

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/support/__init__.py", line 856, in gc_collect
    gc.collect()
ResourceWarning: unclosed file <_io.FileIO name=13 mode='wb' closefd=True>


Traceback (most recent call last):
  File "/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/support/__init__.py", line 856, in gc_collect
    gc.collect()
ResourceWarning: unclosed file <_io.FileIO name=11 mode='wb' closefd=True>

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Ubuntu Shared 3.13 (tier-1) has failed when building commit dbeb29a.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1450/builds/1603) and take a look at the build logs.
  4. Check if the failure is related to this commit (dbeb29a) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1450/builds/1603

Failed tests:

  • test_pyrepl

Failed subtests:

  • test_repl_eio - test.test_pyrepl.test_unix_console.TestUnixConsoleEIOHandling.test_repl_eio

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/subprocess.py", line 1140, in __del__
    _warn("subprocess %s is still running" % self.pid,
ResourceWarning: subprocess 1862649 is still running
Warning -- Unraisable exception
Exception ignored in: <_io.FileIO name=8 mode='rb' closefd=True>
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/unittest/case.py", line 650, in run
    with outcome.testPartExecutor(self):
ResourceWarning: unclosed file <_io.TextIOWrapper name=8 encoding='UTF-8'>
Warning -- Unraisable exception
Exception ignored in: <_io.FileIO name=10 mode='rb' closefd=True>
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/unittest/case.py", line 650, in run
    with outcome.testPartExecutor(self):
ResourceWarning: unclosed file <_io.TextIOWrapper name=10 encoding='UTF-8'>


Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/subprocess.py", line 1140, in __del__
    _warn("subprocess %s is still running" % self.pid,
ResourceWarning: subprocess 1897192 is still running
Warning -- Unraisable exception
Exception ignored in: <_io.FileIO name=8 mode='rb' closefd=True>
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/unittest/case.py", line 650, in run
    with outcome.testPartExecutor(self):
ResourceWarning: unclosed file <_io.TextIOWrapper name=8 encoding='UTF-8'>
Warning -- Unraisable exception
Exception ignored in: <_io.FileIO name=10 mode='rb' closefd=True>
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/unittest/case.py", line 650, in run
    with outcome.testPartExecutor(self):
ResourceWarning: unclosed file <_io.TextIOWrapper name=10 encoding='UTF-8'>


Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/test/test_pyrepl/test_unix_console.py", line 415, in test_repl_eio
    _, err = proc.communicate(timeout=support.LONG_TIMEOUT)
             ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/subprocess.py", line 1222, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
                     ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/subprocess.py", line 2155, in _communicate
    self._check_timeout(endtime, orig_timeout, stdout, stderr)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/subprocess.py", line 1269, in _check_timeout
    raise TimeoutExpired(
    ...<2 lines>...
            stderr=b''.join(stderr_seq) if stderr_seq else None)
subprocess.TimeoutExpired: Command '['/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/python', '-E', '-S', '/srv/buildbot/buildarea/3.13.bolen-ubuntu/build/Lib/test/test_pyrepl/eio_test_script.py']' timed out after 300.0 seconds

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()

6 participants