diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2016-12-30 15:57:15 +0200 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-12-30 15:57:15 +0200 |
| commit | 2fca596fa72783daf315855b4877d1a94b984e0e (patch) | |
| tree | 6abea649fb45b5cff335d594d7f7e0c06408ce88 /astroid/inference.py | |
| parent | e37acdc4bfe7e0d714e86a5c7f5d9f956cef15e5 (diff) | |
| download | astroid-git-2fca596fa72783daf315855b4877d1a94b984e0e.tar.gz | |
Add support for binary operations between classes.
Diffstat (limited to 'astroid/inference.py')
| -rw-r--r-- | astroid/inference.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index 4e46b4e1..112ce986 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -131,7 +131,7 @@ def infer_import(self, context=None, asname=True): yield inferenceutil.do_import_module(self, name) except exceptions.AstroidBuildingError as exc: util.reraise(exceptions.InferenceError(node=self, error=exc, - context=context)) + context=context)) @infer.register(treeabc.ImportFrom) @@ -424,7 +424,12 @@ def _invoke_binop_inference(instance, opnode, op, other, context, method_name, # the inference at this point. raise exceptions.BinaryOperationNotSupportedError - method = instance.getattr(method_name)[0] + try: + methods = dunder_lookup.lookup(instance, method_name) + except exceptions.NotSupportedError: + raise exceptions.BinaryOperationNotSupportedError + + method = methods[0] inferred = next(method.infer(context=context)) return protocols.infer_binary_op(instance, opnode, op, other, context, inferred, nodes) |
