diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-02-17 09:33:10 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-02-17 09:33:10 +0100 |
commit | fc5c916b68953364f03df49918c1a4c6218f4601 (patch) | |
tree | 74a97d66912b4c0164d55d01cd73568f86708978 | |
parent | 799a6102edc88757ee0e35dbfc8db32bac67ad59 (diff) | |
download | astroid-git-fc5c916b68953364f03df49918c1a4c6218f4601.tar.gz |
update inference and infutils from default/stable branch
--HG--
branch : rebuild
-rw-r--r-- | inference.py | 7 | ||||
-rw-r--r-- | infutils.py | 20 |
2 files changed, 19 insertions, 8 deletions
diff --git a/inference.py b/inference.py index 1bd424b7..e0b216be 100644 --- a/inference.py +++ b/inference.py @@ -181,15 +181,16 @@ nodes.AssName.infer_lhs = infer_name # won't work with a path wrapper def infer_callfunc(self, context=None): """infer a CallFunc node by trying to guess what the function returns""" - context = context.clone() - context.callcontext = CallContext(self.args, self.starargs, self.kwargs) + callcontext = context.clone() + callcontext.callcontext = CallContext(self.args, self.starargs, self.kwargs) + callcontext.boundnode = None for callee in self.func.infer(context): if callee is YES: yield callee continue try: if hasattr(callee, 'infer_call_result'): - for infered in callee.infer_call_result(self, context): + for infered in callee.infer_call_result(self, callcontext): yield infered except InferenceError: ## XXX log error ? diff --git a/infutils.py b/infutils.py index 38d32a71..c74fbd54 100644 --- a/infutils.py +++ b/infutils.py @@ -222,12 +222,8 @@ class Instance(Proxy): if '__builtin__.property' in attr.decoratornames(): for infered in attr.infer_call_result(self, context): yield infered - elif attr.type in ('method', 'classmethod'): - # XXX could get some information from the bound node: - # self (if method) or self._proxied (if class method) - yield BoundMethod(attr) else: - yield attr + yield BoundMethod(attr, self) else: yield attr @@ -259,6 +255,9 @@ class Instance(Proxy): def pytype(self): return self._proxied.qname() + def display_type(self): + return 'Instance of' + class UnboundMethod(Proxy): """a special node representing a method not bound to an instance""" @@ -284,9 +283,18 @@ class UnboundMethod(Proxy): class BoundMethod(UnboundMethod): """a special node representing a method bound to an instance""" + def __init__(self, proxy, bound): + UnboundMethod.__init__(self, proxy) + self.bound = bound + def is_bound(self): return True + def infer_call_result(self, caller, context): + context = context.clone() + context.boundnode = self.bound + return self._proxied.infer_call_result(caller, context) + class Generator(Proxy): """a special node representing a generator""" @@ -296,4 +304,6 @@ class Generator(Proxy): def pytype(self): return '__builtin__.generator' + def display_type(self): + return 'Generator' |