diff options
author | Julien Cristau <julien.cristau@logilab.fr> | 2014-06-30 10:38:46 +0200 |
---|---|---|
committer | Julien Cristau <julien.cristau@logilab.fr> | 2014-06-30 10:38:46 +0200 |
commit | ecd1e616e7ba45fc986063d5de3d2bc774f9d206 (patch) | |
tree | 314b6965e3b4721e3112fa5b31377a004baa6a1c /scoped_nodes.py | |
parent | e9ddb83591ba90c1c9ce049067ee5eb48ead1981 (diff) | |
download | astroid-git-ecd1e616e7ba45fc986063d5de3d2bc774f9d206.tar.gz |
Stop looking at the __metaclass__ class attribute for python3
Python 3 only considers the `metaclass` keyword argument.
Diffstat (limited to 'scoped_nodes.py')
-rw-r--r-- | scoped_nodes.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scoped_nodes.py b/scoped_nodes.py index ac77583b..e354c5b8 100644 --- a/scoped_nodes.py +++ b/scoped_nodes.py @@ -1084,8 +1084,8 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin): An explicit defined metaclass is defined either by passing the ``metaclass`` keyword argument - in the class definition line (Python 3) or by - having a ``__metaclass__`` class attribute, or (Python 2) if there are + in the class definition line (Python 3) or (Python 2) by + having a ``__metaclass__`` class attribute, or if there are no explicit bases but there is a global ``__metaclass__`` variable. """ if self._metaclass: @@ -1095,13 +1095,16 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin): if node is not YES) except (InferenceError, StopIteration): return None + if sys.version_info >= (3, ): + return None if '__metaclass__' in self.locals: assignment = self.locals['__metaclass__'][-1] - elif self.bases or sys.version_info >= (3, ): + elif self.bases: return None elif '__metaclass__' in self.root().locals: - assignments = [ass for ass in self.root().locals['__metaclass__'] if ass.lineno < self.lineno] + assignments = [ass for ass in self.root().locals['__metaclass__'] + if ass.lineno < self.lineno] if not assignments: return None assignment = assignments[-1] |