2018-07-31 17:55:14 -03:00
|
|
|
import os
|
|
|
|
import textwrap
|
|
|
|
import unittest
|
|
|
|
|
2020-08-03 13:47:42 -03:00
|
|
|
from test.support import os_helper
|
2018-07-31 17:55:14 -03:00
|
|
|
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
|
2020-08-03 13:47:42 -03:00
|
|
|
with open(os_helper.TESTFN, 'w') as fd:
|
|
|
|
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
2018-07-31 17:55:14 -03:00
|
|
|
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')
|
|
|
|
"""))
|
|
|
|
|
2020-08-03 13:47:42 -03:00
|
|
|
assert_python_ok(os_helper.TESTFN)
|
2018-07-31 17:55:14 -03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|