bpo-28254: _posixsubprocess uses PyGC_Enable/PyGC_Disable (GH-25693)

This commit is contained in:
Victor Stinner 2021-04-28 19:09:29 +02:00 committed by GitHub
parent 3b52c8d66b
commit 103d5e420d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 123 deletions

View file

@ -2147,8 +2147,6 @@ class POSIXProcessTestCase(BaseTestCase):
def test_preexec_gc_module_failure(self):
# This tests the code that disables garbage collection if the child
# process will execute any Python.
def raise_runtime_error():
raise RuntimeError("this shouldn't escape")
enabled = gc.isenabled()
orig_gc_disable = gc.disable
orig_gc_isenabled = gc.isenabled
@ -2165,16 +2163,6 @@ class POSIXProcessTestCase(BaseTestCase):
subprocess.call([sys.executable, '-c', ''],
preexec_fn=lambda: None)
self.assertTrue(gc.isenabled(), "Popen left gc disabled.")
gc.disable = raise_runtime_error
self.assertRaises(RuntimeError, subprocess.Popen,
[sys.executable, '-c', ''],
preexec_fn=lambda: None)
del gc.isenabled # force an AttributeError
self.assertRaises(AttributeError, subprocess.Popen,
[sys.executable, '-c', ''],
preexec_fn=lambda: None)
finally:
gc.disable = orig_gc_disable
gc.isenabled = orig_gc_isenabled