gh-109793: Allow Switching Interpreters During Finalization (gh-109794)

Essentially, we should check the thread ID rather than the thread state pointer.
This commit is contained in:
Eric Snow 2023-09-27 13:41:06 -06:00 committed by GitHub
parent f49958c886
commit 32466c97c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 96 additions and 3 deletions

View file

@ -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):