diff options
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 |