New submission from Sven Brauch:

Here's a patch doing some adjustments to the AST to make it more useful for 
static language analysis, as discussed in 
http://mail.python.org/pipermail/python-dev/2012-December/123320.html.

Changes done:
 * the described fix to attribute ranges
 * add location information for var / kwargs and arguments

Interestingly, this even fixes a bug; compare the locations of the error in the 
following situation:

>>> l = [1, 2, 3]
>>> l[
... 
... 2
... 
... ].Foo

Old error message:
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
AttributeError: 'int' object has no attribute 'Foo'

New error message:
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
AttributeError: 'int' object has no attribute 'Foo'

The new message is obviously more accurate (one could even go as far as saying 
that the first one does not make any sense at all -- what does the expression 
in the slice have to do with the error?).
The same thing happens in similar situations, e.g. with line continuation 
characters, function calls, ... anything multi-line with an error related to 
attribute access.

I hope the patch is okay, if not please let me know what to change. I also hope 
I managed to include all important changes into the patch ;)

----------
components: None
files: python.diff
keywords: patch
messages: 178339
nosy: scummos
priority: normal
severity: normal
status: open
title: Patch: some changes to AST to make it more useful for static language 
analysis
versions: Python 3.4
Added file: http://bugs.python.org/file28462/python.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16795>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to