summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2012-11-07 08:10:49 (GMT)
committerHynek Schlawack <hs@ox.cx>2012-11-07 08:10:49 (GMT)
commit15c02e304852596f2468f5edc32cb57d496ce9ca (patch)
treed4d8df5f6562e2dfdb419a71d7ed3e71d9b037c8 /Lib
parent99dd8b577b3f5073ff8d9dce09a510c34ef9f72f (diff)
parent33363f43e34defa17ad958ad6d718328f9e78db8 (diff)
downloadcpython-15c02e304852596f2468f5edc32cb57d496ce9ca.zip
cpython-15c02e304852596f2468f5edc32cb57d496ce9ca.tar.gz
cpython-15c02e304852596f2468f5edc32cb57d496ce9ca.tar.bz2
Issue #15001: fix segfault on "del sys.module['__main__']"
Patch by Victor Stinner.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_cmd_line.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index bd8a767..7a10288 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -375,6 +375,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()