diff options
Diffstat (limited to 'astroid')
-rw-r--r-- | astroid/inference.py | 5 | ||||
-rw-r--r-- | astroid/tests/unittest_inference.py | 19 |
2 files changed, 19 insertions, 5 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index 12796855..5c83ed5e 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -713,12 +713,7 @@ def _infer_augassign(self, context=None): yield util.Uninferable return - # TODO(cpopa): if we have A() * A(), trying to infer - # the rhs with the same context will result in an - # inference error, so we create another context for it. - # This is a bug which should be fixed in InferenceContext at some point. rhs_context = context.clone() - rhs_context.path = set() for rhs in self.value.infer(context=rhs_context): if rhs is util.Uninferable: # Don't know how to process this. diff --git a/astroid/tests/unittest_inference.py b/astroid/tests/unittest_inference.py index 43180884..4b1b4f16 100644 --- a/astroid/tests/unittest_inference.py +++ b/astroid/tests/unittest_inference.py @@ -4329,5 +4329,24 @@ class ObjectDunderNewTest(unittest.TestCase): self.assertIsInstance(inferred, Instance) +def test_augassign_recursion(): + """Make sure inference doesn't throw a RecursionError + + Regression test for augmented assign dropping context.path + causing recursion errors + + """ + # infinitely recurses in python + code = """ + def rec(): + a = 0 + a += rec() + return a + rec() + """ + cls_node = extract_node(code) + assert next(cls_node.infer()) is util.Uninferable + + if __name__ == '__main__': unittest.main() |