This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scummos
Recipients scummos
Date 2012-12-27.21:44:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1356644683.65.0.359499511153.issue16795@psf.upfronthosting.co.za>
In-reply-to
Content
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 ;)
History
Date User Action Args
2012-12-27 21:44:43scummossetrecipients: + scummos
2012-12-27 21:44:43scummossetmessageid: <1356644683.65.0.359499511153.issue16795@psf.upfronthosting.co.za>
2012-12-27 21:44:43scummoslinkissue16795 messages
2012-12-27 21:44:43scummoscreate