diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-23 13:57:25 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-23 13:57:25 +0100 |
commit | b50e93e14255cb63a60623e214384ecf78dcc483 (patch) | |
tree | 43d84162fa0e2251e434e66239776e86a7c5bd1c /astroid/inference.py | |
parent | 2959dd8c26060d06593e50241b2747ffd3c4d6bb (diff) | |
parent | 6b2f28cf6f4d83112a60946d6dcaa0d889dd516e (diff) | |
download | astroid-b50e93e14255cb63a60623e214384ecf78dcc483.tar.gz |
Merged in dmand/astroid/binop-inference-fix (pull request #92)
Fix binary operator inference issue from pylint's #646
Diffstat (limited to 'astroid/inference.py')
-rw-r--r-- | astroid/inference.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index 3253acb..2943596 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -582,18 +582,18 @@ def _infer_binop(self, context): right = self.right op = self.op - for lhs in left.infer(context=context): + # we use two separate contexts for evaluating lhs and rhs because + # 1. evaluating lhs may leave some undesired entries in context.path + # which may not let us infer right value of rhs + lhs_context = context.clone() + rhs_context = context.clone() + + for lhs in left.infer(context=lhs_context): if lhs is util.YES: # Don't know how to process this. yield util.YES return - # TODO(cpopa): if we have A() * A(), trying to infer - # the rhs with the same context will result in an - # inferrence 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 right.infer(context=rhs_context): if rhs is util.YES: # Don't know how to process this. |