'bool' object is not subscriptable

Bug #1465824 reported by asmeurer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Critical
Unassigned

Bug Description

Running pyflakes on this file https://github.com/conda/conda/blob/10ac568e39086df377c5f6e7fe4ecc41fda8015f/conda/logic.py I get

Traceback (most recent call last):
  File "bin/pyflakes", line 3, in <module>
    main()
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py", line 172, in main
    warnings = checkRecursive(args, reporter)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py", line 129, in checkRecursive
    warnings += checkPath(sourcePath, reporter)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py", line 96, in checkPath
    return check(codestr, filename, reporter)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py", line 57, in check
    w = checker.Checker(tree, filename)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 295, in __init__
    self.runDeferred(self._deferredFunctions)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 332, in runDeferred
    handler()
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 818, in runFunction
    self.handleNode(stmt, node)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 607, in handleNode
    handler(node)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 565, in handleChildren
    self.handleNode(node, tree)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 607, in handleNode
    handler(node)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 729, in NAME
    self.handleNodeStore(node)
  File "/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py", line 514, in handleNodeStore
    if used and used[0] is self.scope and name not in self.scope.globals:
TypeError: 'bool' object is not subscriptable

Revision history for this message
asmeurer (asmeurer) wrote :

The change from 531b6b58 (shown below) seems to be related, but even after reverting it it gives the same error.

@@ -473,8 +477,8 @@ class Checker(object):
                 # if the name was defined in that scope, and the name has
                 # been accessed already in the current scope, and hasn't
                 # been declared global
- if (name in scope and scope[name].used and scope[name].used[0] is self.scope
- and name not in self.scope.globals):
+ used = name in scope and scope[name].used
+ if used and used[0] is self.scope and name not in self.scope.globals:
                     # then it's probably a mistake
                     self.report(messages.UndefinedLocal,
                                 scope[name].used[1], name, scope[name].source)

Revision history for this message
asmeurer (asmeurer) wrote :

I think the problem is https://github.com/pyflakes/pyflakes/pull/19/files#diff-f0429ba5bb9de6e83abcf687aca4c012R702. That change from the older commit still looks wrong, though (used will always be a boolean).

Revision history for this message
asmeurer (asmeurer) wrote :

Oh derp, 'and' returns the object, not a boolean. Still, it's a bit confusing.

The bug itself is fixed by https://github.com/pyflakes/pyflakes/pull/22.

Revision history for this message
Phil Frost (bitglue) wrote :

Released 0.9.2.

Changed in pyflakes:
status: New → Fix Committed
importance: Undecided → Critical
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.