summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-09-27 19:41:06 (GMT)
committerGitHub <noreply@github.com>2023-09-27 19:41:06 (GMT)
commit32466c97c06ee5812923d695195394c736eeb707 (patch)
treee5de52c5dcc30067c6cd79fa97b66d104f911ea4 /Lib
parentf49958c886a2f2608f1008186d588efc2a98b445 (diff)
downloadcpython-32466c97c06ee5812923d695195394c736eeb707.zip
cpython-32466c97c06ee5812923d695195394c736eeb707.tar.gz
cpython-32466c97c06ee5812923d695195394c736eeb707.tar.bz2
gh-109793: Allow Switching Interpreters During Finalization (gh-109794)
Essentially, we should check the thread ID rather than the thread state pointer.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_interpreters.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_interpreters.py b/Lib/test/test_interpreters.py
index 90932c0..9c0dac7 100644
--- a/Lib/test/test_interpreters.py
+++ b/Lib/test/test_interpreters.py
@@ -1,5 +1,6 @@
import contextlib
import os
+import sys
import threading
from textwrap import dedent
import unittest
@@ -487,6 +488,26 @@ class StressTests(TestBase):
pass
+class FinalizationTests(TestBase):
+
+ def test_gh_109793(self):
+ import subprocess
+ argv = [sys.executable, '-c', '''if True:
+ import _xxsubinterpreters as _interpreters
+ interpid = _interpreters.create()
+ raise Exception
+ ''']
+ proc = subprocess.run(argv, capture_output=True, text=True)
+ self.assertIn('Traceback', proc.stderr)
+ if proc.returncode == 0 and support.verbose:
+ print()
+ print("--- cmd unexpected succeeded ---")
+ print(f"stdout:\n{proc.stdout}")
+ print(f"stderr:\n{proc.stderr}")
+ print("------")
+ self.assertEqual(proc.returncode, 1)
+
+
class TestIsShareable(TestBase):
def test_default_shareables(self):