Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exercise': 0.03; 'failing': 0.05; 'method,': 0.07; 'subject:missing': 0.07; 'subject:How': 0.09; 'added.': 0.09; 'ast': 0.09; 'creighton': 0.09; 'fixed,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'throw': 0.09; 'jan': 0.11; '2.7': 0.13; 'skip:f 30': 0.15; 'doc,': 0.16; 'fixing.': 0.16; 'nodes.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'subject:debug': 0.16; 'subject:required': 0.16; 'wrote:': 0.16; 'copied': 0.18; 'example.': 0.18; 'laura': 0.18; 'creates': 0.18; '>>>': 0.20; 'changes': 0.20; 'fix': 0.21; 'trying': 0.22; 'doc': 0.22; 'lawrence': 0.22; 'am,': 0.23; '2015': 0.23; "i've": 0.24; 'header :In-Reply-To:1': 0.24; 'mon,': 0.24; 'url:bugs': 0.24; 'sort': 0.25; 'example': 0.25; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'error': 0.27; 'checking': 0.27; 'converting': 0.27; 'locations': 0.27; "doesn't": 0.28; 'node': 0.29; 'str': 0.29; 'terry': 0.29; 'function': 0.30; 'maybe': 0.31; 'code': 0.31; 'skip:p 30': 0.32; 'url:python': 0.33; 'surprised': 0.33; 'subject:?': 0.34; 'to:addr:python-list': 0.35; 'replaced': 0.35; 'something': 0.35; 'copying': 0.35; 'but': 0.36; 'being': 0.36; 'url:org': 0.36; 'there': 0.36; 'closing': 0.36; 'subject:" ': 0.36; 'should': 0.37; 'subject:: ': 0.37; 'missing': 0.37; 'instead': 0.38; 'rather': 0.38; 'received:org': 0.38; 'someone': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'mark': 0.40; 'field': 0.60; 'skip:n 10': 0.63; 'results': 0.66; 'subscript': 0.66; 'subject': 0.68; 'frustrating': 0.84; 'recursively?': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: How to debug TypeError: required field "lineno" missing from expr? Date: Mon, 29 Jun 2015 16:59:23 -0400 References: <201506290708.t5T78rhr024655@fido.openend.se> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435611574 news.xs4all.nl 2952 [2001:888:2000:d::a6]:53877 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93296 On 6/29/2015 7:17 AM, Terry Reedy wrote: > On 6/29/2015 3:08 AM, Laura Creighton wrote: >> In a message of Mon, 29 Jun 2015 02:14:43 +0100, Mark Lawrence writes: >>> Purely as an exercise I've been converting Grant Jenks' pypatt[1] from >>> 2.7 to 3.4. 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. >> >> Are you trying to use ast.copy_location recursively somewhere? >> http://bugs.python.org/issue3530 Maybe you have found something else >> that doesn't work recursively? The issue is that copy_location is not recursive and does not fix children of the node being fixed, whereas the example method, copied from the NodeTransformer doc, creates 3 new nodes, not just 1, that need fixing. I reopened the issue as a doc issue to fix the example and recommend the use of recursive fix_missing_locations() instead of the non-recursive copy_location. The only other location-related function in ast is increment_lineno, which also works on multiple nodes. I would not be surprised is Mark's issue results from Mark or someone else copying the bad doc example. > I do not understand the closing of this issue given that a) the failing > part of the code is copied from the doc (3.4 has the same in the > docstring) and b) that there is no recursion for a single node ast, > which the example should be. The original ast is actually an Expression with a Name. But the issue is that the Name is replaced with a Subscript with Name and Str children and all three need locations added. > The error message comes from > F:\Python\dev\34\Python\Python-ast.c: 3752: > PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from > stmt"); -- Terry Jan Reedy