Message 229138 - Python tracker

Message229138

Author Edward.K..Ream
Recipients Aivar.Annamaa, Edward.K..Ream, r.david.murray
Date 2014-10-12.10:50:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1413111044.73.0.944887191582.issue22616@psf.upfronthosting.co.za>
In-reply-to
Content
I urge the Python development team to fix this and the related bugs given in the Post Script. The lack of an easy way of associating ast nodes with text ranges in the original sources is arguably the biggest hole in the Python api.

These bugs have immediate, severe, practical consequences for any tool that attempts to regularize (pep 8) or beautify Python code.

Consider the code for PythonTidy:
http://lacusveris.com/PythonTidy/PythonTidy-1.23.python

Every version has had bugs in this area arising from difficult workarounds to the hole in the API.  The entire Comments class is a horror directly related to these issues.

Consider Aivar's workaround to these bugs:
https://bitbucket.org/plas/thonny/src/8cdaa41aca7a5cc0b31618b6f1631d360c488196/src/ast_utils.py?at=default
See the docstring for def fix_ast_problems.  This is an absurdly difficult solution to what should be a trivial problem.

It's impossible to build reliable software using such heroic hacks.  The additional bugs listed below further complicate a nightmarish task.

In short, these bugs are *not* minor little nits.  They are preventing the development of reliable source-code tools.

Edward K. Ream

P.S. Here are the related bugs:

http://bugs.python.org/issue10769
Allow connecting AST nodes with corresponding source ranges

http://bugs.python.org/issue21295
Python 3.4 gives wrong col_offset for Call nodes returned from ast.parse

http://bugs.python.org/issue18374
ast.parse gives wrong position (col_offset) for some BinOp-s

http://bugs.python.org/issue16806
col_offset is -1 and lineno is wrong for multiline string expressions

EKR
History
Date User Action Args
2014-10-12 10:50:44Edward.K..Reamsetrecipients: + Edward.K..Ream, r.david.murray, Aivar.Annamaa
2014-10-12 10:50:44Edward.K..Reamsetmessageid: <1413111044.73.0.944887191582.issue22616@psf.upfronthosting.co.za>
2014-10-12 10:50:44Edward.K..Reamlinkissue22616 messages
2014-10-12 10:50:43Edward.K..Reamcreate