mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
f49958c886
commit
32466c97c0
7 changed files with 96 additions and 3 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue