diff options
author | cpopa <devnull@localhost> | 2014-04-30 11:37:54 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-04-30 11:37:54 +0300 |
commit | 6bbd339901c219edec1debb47cd13a773054b5be (patch) | |
tree | 0a7de87cca8ba2e59ea9787d8f7f756720388e8b | |
parent | 495951ce43a6eb572d52b9e0f22b51104321c1b8 (diff) | |
download | astroid-ancestors.tar.gz |
Simplify the lookup for the metaclass; add comments for the YES node tests.ancestors
-rw-r--r-- | scoped_nodes.py | 10 | ||||
-rw-r--r-- | test/unittest_python3.py | 1 | ||||
-rw-r--r-- | test/unittest_scoped_nodes.py | 1 |
3 files changed, 6 insertions, 6 deletions
diff --git a/scoped_nodes.py b/scoped_nodes.py index 067f01f..20bb664 100644 --- a/scoped_nodes.py +++ b/scoped_nodes.py @@ -1055,12 +1055,10 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin): if self._metaclass: # Expects this from Py3k TreeRebuilder try: - infered = next(self._metaclass.infer()) - except InferenceError: - return - if infered is YES: # don't expose it - return None - return infered + return next(node for node in self._metaclass.infer() + if node is not YES) + except (InferenceError, StopIteration): + return try: meta = self.getattr('__metaclass__')[0] diff --git a/test/unittest_python3.py b/test/unittest_python3.py index 9e80406..114e3d3 100644 --- a/test/unittest_python3.py +++ b/test/unittest_python3.py @@ -133,6 +133,7 @@ class Python3TC(TestCase): @require_version('3.0') def test_metaclass_yes_leak(self): astroid = self.builder.string_build(dedent(""" + # notice `ab` instead of `abc` from ab import ABCMeta class Meta(metaclass=ABCMeta): pass diff --git a/test/unittest_scoped_nodes.py b/test/unittest_scoped_nodes.py index 3d05318..6c56c55 100644 --- a/test/unittest_scoped_nodes.py +++ b/test/unittest_scoped_nodes.py @@ -718,6 +718,7 @@ def g2(): def test_metaclass_yes_leak(self): astroid = abuilder.string_build(dedent(""" + # notice `ab` instead of `abc` from ab import ABCMeta class Meta(object): |