Skip to content

Commit 4d8ab00

Browse files
generatedunixname1734921407115435facebook-github-bot
authored andcommitted
Import upstream CPython branch '3.14'
Summary: Python `3.14.0rc1+` (`3.14`) was **published** on 2025-08-04 13:01:39+00:00. # Commit Info Base: (`3.14.0rc1+`) - `134ca903b30d891c9b9bc8fe565139251d30fcbd` (commit date: 2025-08-04 10:34:16+00:00) Imported: (`3.14.0rc1+`) - `3.14` (commit date: 2025-08-04 13:01:39+00:00) # Files added ```javascript Misc/NEWS.d/next/Library/2025-07-25-09-21-56.gh-issue-130522.Crwq68.rst ``` Reviewed By: zsol, itamaro Differential Revision: D79638133 fbshipit-source-id: 8f72a0e8e0ce40a123794d92367d9316487f2586
1 parent 3fffad2 commit 4d8ab00

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

Lib/test/test_threading.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,23 @@ def modify_file():
19931993
t.start()
19941994
t.join()
19951995

1996+
def test_dummy_thread_on_interpreter_shutdown(self):
1997+
# GH-130522: When `threading` held a reference to itself and then a
1998+
# _DummyThread() object was created, destruction of the dummy thread
1999+
# would emit an unraisable exception at shutdown, due to a lock being
2000+
# destroyed.
2001+
code = """if True:
2002+
import sys
2003+
import threading
2004+
2005+
threading.x = sys.modules[__name__]
2006+
x = threading._DummyThread()
2007+
"""
2008+
rc, out, err = assert_python_ok("-c", code)
2009+
self.assertEqual(rc, 0)
2010+
self.assertEqual(out, b"")
2011+
self.assertEqual(err, b"")
2012+
19962013

19972014
class ThreadRunFail(threading.Thread):
19982015
def run(self):

Lib/threading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ def __init__(self, dummy_thread):
14211421
# the related _DummyThread will be kept forever!
14221422
_thread_local_info._track_dummy_thread_ref = self
14231423

1424-
def __del__(self):
1424+
def __del__(self, _active_limbo_lock=_active_limbo_lock, _active=_active):
14251425
with _active_limbo_lock:
14261426
if _active.get(self._tident) is self._dummy_thread:
14271427
_active.pop(self._tident, None)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix unraisable :exc:`TypeError` raised during :term:`interpreter shutdown`
2+
in the :mod:`threading` module.

0 commit comments

Comments
 (0)