diff options
author | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2009-03-24 12:57:46 +0100 |
---|---|---|
committer | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2009-03-24 12:57:46 +0100 |
commit | 89a9270cb3dcf6c9dbcf8dcefd1e26e7517b099e (patch) | |
tree | 9a4eb3243705d2e64ff4faa7144d15eec204c1b6 /scoped_nodes.py | |
parent | 3e9d8e5bfac1ec9287c75cd8e1754d1749a2aa48 (diff) | |
download | astroid-git-89a9270cb3dcf6c9dbcf8dcefd1e26e7517b099e.tar.gz |
introduce UnboundMethod / rename InstanceMethod to BoundMethod, handle .im_func
Diffstat (limited to 'scoped_nodes.py')
-rw-r--r-- | scoped_nodes.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/scoped_nodes.py b/scoped_nodes.py index fa1f6dae..10344dd4 100644 --- a/scoped_nodes.py +++ b/scoped_nodes.py @@ -39,8 +39,8 @@ from logilab.astng.nodes import Arguments, Class, Const, Function, GenExpr, \ From, Lambda, Module, Name, Pass, Raise, Tuple, List, Dict, Yield, \ DelAttr, DelName, const_factory as cf from logilab.astng.utils import extend_class -from logilab.astng.infutils import YES, InferenceContext, Instance, copy_context, \ - unpack_infer, _infer_stmts +from logilab.astng.infutils import YES, InferenceContext, Instance, \ + UnboundMethod, copy_context, unpack_infer, _infer_stmts from logilab.astng.nodes_as_string import as_string @@ -52,6 +52,12 @@ def remove_nodes(func, cls): return nodes return wrapper +def function_to_unbound_method(func): + def wrapper(*args, **kwargs): + return [isinstance(n, Function) and UnboundMethod(n) or n + for n in func(*args, **kwargs)] + return wrapper + # module class dict/iterator interface ######################################## class LocalsDictMixIn(object): @@ -718,7 +724,7 @@ class ClassNG(object): except NotFoundError: continue raise NotFoundError(name) - getattr = remove_nodes(getattr, DelAttr) + getattr = function_to_unbound_method(remove_nodes(getattr, DelAttr)) def igetattr(self, name, context=None): """infered getattr, need special treatment in class to handle |