blob: 5f7d56474f0d88cb76278b8cf3dbd4eee23fb560 [file] [log] [blame]
costypetrisor8ed317f2018-07-31 20:55:14 +00001import os
2import textwrap
3import unittest
4
Hai Shibb0424b2020-08-04 00:47:42 +08005from test.support import os_helper
costypetrisor8ed317f2018-07-31 20:55:14 +00006from test.support.script_helper import assert_python_ok
7
8
9class TestLLTrace(unittest.TestCase):
10
11 def test_lltrace_does_not_crash_on_subscript_operator(self):
12 # If this test fails, it will reproduce a crash reported as
13 # bpo-34113. The crash happened at the command line console of
14 # debug Python builds with __ltrace__ enabled (only possible in console),
15 # when the interal Python stack was negatively adjusted
Hai Shibb0424b2020-08-04 00:47:42 +080016 with open(os_helper.TESTFN, 'w') as fd:
17 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
costypetrisor8ed317f2018-07-31 20:55:14 +000018 fd.write(textwrap.dedent("""\
19 import code
20
21 console = code.InteractiveConsole()
22 console.push('__ltrace__ = 1')
23 console.push('a = [1, 2, 3]')
24 console.push('a[0] = 1')
25 print('unreachable if bug exists')
26 """))
27
Hai Shibb0424b2020-08-04 00:47:42 +080028 assert_python_ok(os_helper.TESTFN)
costypetrisor8ed317f2018-07-31 20:55:14 +000029
30if __name__ == "__main__":
31 unittest.main()