AttributeError: 'ModuleScope' object has no attribute 'returnValue'

Bug #1332451 reported by keul
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Medium
Unassigned

Bug Description

Running the pyflakes checker on a code I get this:

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/api.py", line 88, in checkPath
    return check(codestr, filename, reporter)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/api.py", line 58, in check
    w = checker.Checker(tree, filename)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py", line 294, in __init__
    self.handleChildren(tree)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py", line 547, in handleChildren
    self.handleNode(node, tree)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py", line 589, in handleNode
    handler(node)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py", line 547, in handleChildren
    self.handleNode(node, tree)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py", line 589, in handleNode
    handler(node)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py", line 696, in RETURN
    if node.value and not self.scope.returnValue:
AttributeError: 'ModuleScope' object has no attribute 'returnValue'

Unluckily I'm not able to check the code that raise the error (it's a 3rd party legacy code full of errors).

I skipped the issue changing the line 696 to:

    if node.value and hasattr(self.scope, 'returnValue') and not self.scope.returnValue:

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

I can reproduce this case with the following (invalid) snippet:

class Foo(object):
    return

All versions of Python.

Changed in pyflakes:
importance: Undecided → Medium
milestone: none → 0.8.2
status: New → Confirmed
Revision history for this message
Adi Roiban (adiroiban) wrote :

I have created a pull request to work on this https://github.com/pyflakes/pyflakes/pull/13

It looks like code on master already handles this condition so I think that we should not merge pull #13 but just close this tickets as solved.

Thanks!

Revision history for this message
Gil (gforcada) wrote :

I hit the same error... can we get a new release please? I see that there are quite a few changes pending to be released...

Phil Frost (bitglue)
Changed in pyflakes:
status: Confirmed → Fix Committed
Phil Frost (bitglue)
Changed in pyflakes:
status: Fix Committed → Fix Released
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.