How to debug TypeError: required field "lineno" missing from expr?

Terry Reedy tjreedy at udel.edu
Sun Jun 28 22:20:48 EDT 2015


On 6/28/2015 9:14 PM, Mark Lawrence wrote:
> Purely as an exercise I've been converting Grant Jenks' pypatt[1] from
> 2.7 to 3.4.

With 2to3 or by hand?

>  I've managed to sort out most of the required changes by
> checking on what I can see with an AST pretty printer[2].  So it's
> rather frustrating to have the compile stage throw the error given in
> the subject line.
>
> The code has a call to the ast fix_missing_locations function.

ast.fix_missing_locations does not have a raise statement

>  I'm aware of the Armin Ronacher tweet[3] stating
>
> <quote>
> "TypeError: required field "lineno" missing from stmt" — no, what you
> actually mean is "tuple is not a statement'.
> </quote>

As near as I can tell, it is impossible for lineno to be missing from a 
call to the inner function _fix.  Grepping for "TypeError: required 
field" in 3.4 .c and .py files (with Idle) does not return any hits.

astpp.py does not raise that particular error either.

A random tweet without context or example is not terribly helpful.

> but I don't think this is the problem.  Still I've clearly managed to
> screw something up somewhere along so line, so any bright ideas as to
> how I can proceed?

How many times have you asked people asking such questions to post both 
the complete traceback and the code.  Where does the traceback say the 
exception is from?  The What is the code that compiled with 2.7 and the 
(modified?) code that does not compile.  What is a minimal example that 
exhibits the problem?

-- 
Terry Jan Reedy





More information about the Python-list mailing list