If there is too many indexes python crashes: a[0][0][0][0].... segfault at 7ffd25fe6ff8 ip 0000564528c8cfe6 sp 00007ffd25fe7000 error 6 in python2.7[564528b6a000+324000] code to generate code: >>> i="[0]"*200000 >>> file('/tmp/bad_python.py','w').write('a=[]\na.append(a)\nprint(type(a'+i+'))\n') python2 /tmp/bad_python.py Segmentation fault (core dumped) python3 /tmp/bad_python.py RecursionError: maximum recursion depth exceeded during compilation Just in case I upload generated code. This bug affects both eval() function and python interpreter.
To be clear, as the title and version suggest, the bug is the 2.7 segfault versus the 3.x exception during compile. It is normal for the compiler to have limits and to exit when they are exceeded. I have no idea if the 3.x code can be backported. I added ast/compiler experts to the nosy list.
We have quite a few of them: https://github.com/python/cpython/tree/master/Lib/test/crashers Python 2.7 is ancient, so our tolerance for intrusive interpreter level fixes to address rare problems that are easy to avoid at the development level is pretty low. Fixing those kinds of problems in Python 3.x is encouraged, but still not necessarily easy.