◐ Shell
clean mode source ↗

Message 218383 - Python tracker

With the development version (Python 3.5), I reproduce the crash when Python is compiled in debug mode:

$ ./python astlinenotest.py 
python: Python/compile.c:3975: assemble_lnotab: Assertion `d_lineno >= 0' failed.
Abandon (core dumped)

The problem is that astlinenotest.py creates an AST node without lineno information, which makes an assertion to fail in the compiler.

In my astoptimizer project, I use this function to not have to worry of the lineno:

def copy_lineno(node, new_node):
    ast.fix_missing_locations(new_node)
    ast.copy_location(new_node, node)
    return new_node