diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-03-22 17:09:15 +0100 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2010-03-22 17:09:15 +0100 |
commit | 293febbe9f5b9ed6a7c1e685243f83efce80df2d (patch) | |
tree | 6faf4de0f9fa4cb3a5e5ae248bd58c920e0a07dc /checkers/variables.py | |
parent | 529ec1d5672718b1d99a17edc0b642e6d369a1e9 (diff) | |
download | pylint-293febbe9f5b9ed6a7c1e685243f83efce80df2d.tar.gz |
test and fix crash on global w/ 'virtual' nodes such as __file__, __module__, etc.
Diffstat (limited to 'checkers/variables.py')
-rw-r--r-- | checkers/variables.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/checkers/variables.py b/checkers/variables.py index e7b7fd5..054d291 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -264,6 +264,10 @@ builtins. Remember that you should avoid to define new builtins when possible.' # unassigned global, skip assign_nodes = [] for anode in assign_nodes: + if anode.parent is None: + # node returned for builtin attribute such as __file__, + # __doc__, etc... + continue if anode.frame() is frame: # same scope level assignment break @@ -274,6 +278,9 @@ builtins. Remember that you should avoid to define new builtins when possible.' if not assign_nodes: continue for anode in assign_nodes: + if anode.parent is None: + self.add_message('W0622', args=name, node=node) + break if anode.frame() is module: # module level assignment break |