diff options
author | Hynek Schlawack <hs@ox.cx> | 2012-11-07 08:07:22 (GMT) |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2012-11-07 08:07:22 (GMT) |
commit | 33363f43e34defa17ad958ad6d718328f9e78db8 (patch) | |
tree | af52bccb1704c7a4eb3549436ea8ac1848c63b68 /Lib/test | |
parent | c3fb3c3fa0688327d31715cb374c6825158f9d75 (diff) | |
parent | 5c6b3e214ce3506c454e8009602f0de651cc7922 (diff) | |
download | cpython-33363f43e34defa17ad958ad6d718328f9e78db8.zip cpython-33363f43e34defa17ad958ad6d718328f9e78db8.tar.gz cpython-33363f43e34defa17ad958ad6d718328f9e78db8.tar.bz2 |
Issue #15001: fix segfault on "del sys.module['__main__']"
Patch by Victor Stinner.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_cmd_line.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 7644db2..2b0c6e2 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -358,6 +358,18 @@ class CmdLineTest(unittest.TestCase): self.assertEqual(rc, 0) self.assertIn(b'random is 1', out) + def test_del___main__(self): + # Issue #15001: PyRun_SimpleFileExFlags() did crash because it kept a + # borrowed reference to the dict of __main__ module and later modify + # the dict whereas the module was destroyed + filename = test.support.TESTFN + self.addCleanup(test.support.unlink, filename) + with open(filename, "w") as script: + print("import sys", file=script) + print("del sys.modules['__main__']", file=script) + assert_python_ok(filename) + + def test_main(): test.support.run_unittest(CmdLineTest) test.support.reap_children() |