pyflakes crashes with AttributeError. No attribute 'varargannotation'

Bug #1295554 reported by Fredrik Hedman
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
High
Unassigned

Bug Description

As of python 3.4.0 pyflakes will crash in checker.py:

File "../site-packages/pyflakes/checker.py", line 730, in LAMBDA
    for annotation in (node.args.varargannotation,
AttributeError: 'arguments' object has no attribute 'varargannotation'

Code that generates the error

            if hasattr(node, 'returns'): # Only for FunctionDefs
                for annotation in (node.args.varargannotation,
                                   node.args.kwargannotation, node.returns):
             self.handleNode(annotation, node)

It seems that the module ast has changed from python 3.3 to 3.4. The attribute 'varargannotation' is no longer present in the newer version.

In 3.3 the documentation: (http://docs.python.org/3.3/library/ast.html#abstract-grammar)

arguments = (arg* args, identifier? vararg, expr? varargannotation,
                     arg* kwonlyargs, identifier? kwarg,
                     expr? kwargannotation, expr* defaults,
                     expr* kw_defaults)

In 3.4 the dokumentation says: (http://docs.python.org/3.4/library/ast.html#abstract-grammar)

arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,
                 arg? kwarg, expr* defaults)

Revision history for this message
Fredrik Hedman (moln) wrote :

Circumventing the reported error reveals a second bug:

AttributeError: 'FlakesChecker' object has no attribute 'NAMECONSTANT'. I assume this has to do with the new Enumeration type in 3.4. Anyhow a second fix avoids also this crash to get it back to a "working" state.

These fixes should just be considered a hint at how to fix these problems.

Revision history for this message
Florent (florent.x) wrote :

Alreasy fixed in trunk.

Changed in pyflakes:
importance: Undecided → High
milestone: none → 0.8
status: New → Fix Committed
Florent (florent.x)
Changed in pyflakes:
status: Fix Committed → Fix Released
Revision history for this message
Sorin Sbarnea (ssbarnea) wrote :

This tells me that people are probably not using not using pyflakes with python 3.5 or 3.4

Revision history for this message
Sorin Sbarnea (ssbarnea) wrote :

Here is another one that seems very similar to me:

  File "/Users/sorins/bmll/flare/env/lib/python3.5/site-packages/pyflakes/checker.py", line 462, in getNodeHandler
    self._nodeHandlers[node_class] = handler = getattr(self, nodeType)
AttributeError: 'FlakesChecker' object has no attribute 'MATMULT'

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.