diff options
| author | costypetrisor <costypetrisor@users.noreply.github.com> | 2018-07-31 20:55:14 +0000 |
|---|---|---|
| committer | Victor Stinner <vstinner@redhat.com> | 2018-07-31 22:55:14 +0200 |
| commit | 8ed317f1ca42a43df14282bbc3ccc0b5610432f4 (patch) | |
| tree | 608abbe452767ddbd65946d45665082c2af4e773 /Lib/test | |
| parent | 944451cd8d3e897138f4b43569de13cd081ee251 (diff) | |
| download | cpython-git-8ed317f1ca42a43df14282bbc3ccc0b5610432f4.tar.gz | |
bpo-34113: Fix a crash when using LLTRACE is on (GH-8517)
Fix a crash on negative STACKADJ() when Low-Level trace (LLTRACE) is enabled.
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_lltrace.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_lltrace.py b/Lib/test/test_lltrace.py new file mode 100644 index 0000000000..49fae81eef --- /dev/null +++ b/Lib/test/test_lltrace.py @@ -0,0 +1,31 @@ +import os +import textwrap +import unittest + +from test import support +from test.support.script_helper import assert_python_ok + + +class TestLLTrace(unittest.TestCase): + + def test_lltrace_does_not_crash_on_subscript_operator(self): + # If this test fails, it will reproduce a crash reported as + # bpo-34113. The crash happened at the command line console of + # debug Python builds with __ltrace__ enabled (only possible in console), + # when the interal Python stack was negatively adjusted + with open(support.TESTFN, 'w') as fd: + self.addCleanup(os.unlink, support.TESTFN) + fd.write(textwrap.dedent("""\ + import code + + console = code.InteractiveConsole() + console.push('__ltrace__ = 1') + console.push('a = [1, 2, 3]') + console.push('a[0] = 1') + print('unreachable if bug exists') + """)) + + assert_python_ok(support.TESTFN) + +if __name__ == "__main__": + unittest.main() |
