Show More
@@ -195,14 +195,14 b' def _method_magic_marker(magic_kind):' | |||
|
195 | 195 | if callable(arg): |
|
196 | 196 | # "Naked" decorator call (just @foo, no args) |
|
197 | 197 | func = arg |
|
198 |
name = func. |
|
|
198 | name = func.__name__ | |
|
199 | 199 | retval = decorator(call, func) |
|
200 | 200 | record_magic(magics, magic_kind, name, name) |
|
201 | 201 | elif isinstance(arg, string_types): |
|
202 | 202 | # Decorator called with arguments (@foo('bar')) |
|
203 | 203 | name = arg |
|
204 | 204 | def mark(func, *a, **kw): |
|
205 |
record_magic(magics, magic_kind, name, func. |
|
|
205 | record_magic(magics, magic_kind, name, func.__name__) | |
|
206 | 206 | return decorator(call, func) |
|
207 | 207 | retval = mark |
|
208 | 208 | else: |
@@ -240,7 +240,7 b' def _function_magic_marker(magic_kind):' | |||
|
240 | 240 | if callable(arg): |
|
241 | 241 | # "Naked" decorator call (just @foo, no args) |
|
242 | 242 | func = arg |
|
243 |
name = func. |
|
|
243 | name = func.__name__ | |
|
244 | 244 | ip.register_magic_function(func, magic_kind, name) |
|
245 | 245 | retval = decorator(call, func) |
|
246 | 246 | elif isinstance(arg, string_types): |
@@ -426,7 +426,7 b' class MagicsManager(Configurable):' | |||
|
426 | 426 | # Create the new method in the user_magics and register it in the |
|
427 | 427 | # global table |
|
428 | 428 | validate_type(magic_kind) |
|
429 |
magic_name = func. |
|
|
429 | magic_name = func.__name__ if magic_name is None else magic_name | |
|
430 | 430 | setattr(self.user_magics, magic_name, func) |
|
431 | 431 | record_magic(self.magics, magic_kind, magic_name, func) |
|
432 | 432 |
@@ -193,8 +193,8 b' def getargspec(obj):' | |||
|
193 | 193 | func_obj = obj.__call__ |
|
194 | 194 | else: |
|
195 | 195 | raise TypeError('arg is not a Python function') |
|
196 |
args, varargs, varkw = inspect.getargs(func_obj. |
|
|
197 |
return args, varargs, varkw, func_obj. |
|
|
196 | args, varargs, varkw = inspect.getargs(func_obj.__code__) | |
|
197 | return args, varargs, varkw, func_obj.__defaults__ | |
|
198 | 198 | |
|
199 | 199 | |
|
200 | 200 | def format_argspec(argspec): |
@@ -198,7 +198,7 b' def findsource(object):' | |||
|
198 | 198 | if ismethod(object): |
|
199 | 199 | object = object.im_func |
|
200 | 200 | if isfunction(object): |
|
201 |
object = object. |
|
|
201 | object = object.__code__ | |
|
202 | 202 | if istraceback(object): |
|
203 | 203 | object = object.tb_frame |
|
204 | 204 | if isframe(object): |
@@ -136,7 +136,7 b' class FunctionMaker(object):' | |||
|
136 | 136 | func.__name__ = self.name |
|
137 | 137 | func.__doc__ = getattr(self, 'doc', None) |
|
138 | 138 | func.__dict__ = getattr(self, 'dict', {}) |
|
139 |
func. |
|
|
139 | func.__defaults__ = getattr(self, 'defaults', ()) | |
|
140 | 140 | func.__kwdefaults__ = getattr(self, 'kwonlydefaults', None) |
|
141 | 141 | func.__annotations__ = getattr(self, 'annotations', None) |
|
142 | 142 | callermodule = sys._getframe(3).f_globals.get('__name__', '?') |
@@ -200,7 +200,7 b' def decorator(caller, func=None):' | |||
|
200 | 200 | decorator(caller, func) decorates a function using a caller. |
|
201 | 201 | """ |
|
202 | 202 | if func is not None: # returns a decorated function |
|
203 |
evaldict = func. |
|
|
203 | evaldict = func.__globals__.copy() | |
|
204 | 204 | evaldict['_call_'] = caller |
|
205 | 205 | evaldict['_func_'] = func |
|
206 | 206 | return FunctionMaker.create( |
@@ -211,7 +211,7 b' def decorator(caller, func=None):' | |||
|
211 | 211 | return partial(decorator, caller) |
|
212 | 212 | # otherwise assume caller is a function |
|
213 | 213 | first = inspect.getargspec(caller)[0][0] # first arg |
|
214 |
evaldict = caller. |
|
|
214 | evaldict = caller.__globals__.copy() | |
|
215 | 215 | evaldict['_call_'] = caller |
|
216 | 216 | evaldict['decorator'] = decorator |
|
217 | 217 | return FunctionMaker.create( |
@@ -56,7 +56,7 b' class dependent(object):' | |||
|
56 | 56 | |
|
57 | 57 | def __init__(self, f, df, *dargs, **dkwargs): |
|
58 | 58 | self.f = f |
|
59 |
self. |
|
|
59 | self.__name__ = getattr(f, '__name__', 'f') | |
|
60 | 60 | self.df = df |
|
61 | 61 | self.dargs = dargs |
|
62 | 62 | self.dkwargs = dkwargs |
@@ -71,7 +71,7 b' class dependent(object):' | |||
|
71 | 71 | if not py3compat.PY3: |
|
72 | 72 | @property |
|
73 | 73 | def __name__(self): |
|
74 |
return self. |
|
|
74 | return self.__name__ | |
|
75 | 75 | |
|
76 | 76 | @interactive |
|
77 | 77 | def _require(*modules, **mapping): |
@@ -52,7 +52,7 b' from .dependency import Dependency' | |||
|
52 | 52 | @decorator |
|
53 | 53 | def logged(f,self,*args,**kwargs): |
|
54 | 54 | # print ("#--------------------") |
|
55 |
self.log.debug("scheduler::%s(*%s,**%s)", f. |
|
|
55 | self.log.debug("scheduler::%s(*%s,**%s)", f.__name__, args, kwargs) | |
|
56 | 56 | # print ("#--") |
|
57 | 57 | return f(self,*args, **kwargs) |
|
58 | 58 |
@@ -95,7 +95,7 b' class DocTestFinder(doctest.DocTestFinder):' | |||
|
95 | 95 | if module is None: |
|
96 | 96 | return True |
|
97 | 97 | elif inspect.isfunction(object): |
|
98 |
return module.__dict__ is object. |
|
|
98 | return module.__dict__ is object.__globals__ | |
|
99 | 99 | elif inspect.isbuiltin(object): |
|
100 | 100 | return module.__name__ == object.__module__ |
|
101 | 101 | elif inspect.isclass(object): |
@@ -36,8 +36,8 b' def getargspec(obj):' | |||
|
36 | 36 | func_obj = obj.im_func |
|
37 | 37 | else: |
|
38 | 38 | raise TypeError('arg is not a Python function') |
|
39 |
args, varargs, varkw = inspect.getargs(func_obj. |
|
|
40 |
return args, varargs, varkw, func_obj. |
|
|
39 | args, varargs, varkw = inspect.getargs(func_obj.__code__) | |
|
40 | return args, varargs, varkw, func_obj.__defaults__ | |
|
41 | 41 | |
|
42 | 42 | #----------------------------------------------------------------------------- |
|
43 | 43 | # Testing functions |
@@ -105,9 +105,9 b' class CannedFunction(CannedObject):' | |||
|
105 | 105 | |
|
106 | 106 | def __init__(self, f): |
|
107 | 107 | self._check_type(f) |
|
108 |
self.code = f. |
|
|
109 |
if f. |
|
|
110 |
self.defaults = [ can(fd) for fd in f. |
|
|
108 | self.code = f.__code__ | |
|
109 | if f.__defaults__: | |
|
110 | self.defaults = [ can(fd) for fd in f.__defaults__ ] | |
|
111 | 111 | else: |
|
112 | 112 | self.defaults = None |
|
113 | 113 | self.module = f.__module__ or '__main__' |
General Comments 0
You need to be logged in to leave comments.
Login now