[FIX] function introspection attributes
Introspection attributes on function and methods were originally
prefixed with func_ or im_ e.g. im_class or func_name. For coherence with the
rest of the data model, Python 3 added dunder attributes (__func__,
__code__) and removed the old style, the dunder attributes were
backported to Python 2.6.
Use dunder attributes everywhere we're currently using func_* or im_*
attributes.
Fixers:
lib2to3.fixes.fix_funcattrs
lib2to3.fixes.fix_methodattrs
#8530
This commit is contained in:
+2
-2
@@ -966,8 +966,8 @@ def routing_map(modules, nodb_only, converters=None):
|
||||
routing = dict(type='http', auth='user', methods=None, routes=None)
|
||||
methods_done = list()
|
||||
# update routing attributes from subclasses(auth, methods...)
|
||||
for claz in reversed(mv.im_class.mro()):
|
||||
fn = getattr(claz, mv.func_name, None)
|
||||
for claz in reversed(mv.__self__.__class__.mro()):
|
||||
fn = getattr(claz, mv.__name__, None)
|
||||
if fn and hasattr(fn, 'routing') and fn not in methods_done:
|
||||
methods_done.append(fn)
|
||||
routing.update(fn.routing)
|
||||
|
||||
+2
-2
@@ -217,8 +217,8 @@ def log_ormcache_stats(sig=None, frame=None):
|
||||
|
||||
def get_cache_key_counter(bound_method, *args, **kwargs):
|
||||
""" Return the cache, key and stat counter for the given call. """
|
||||
model = bound_method.im_self
|
||||
ormcache = bound_method.clear_cache.im_self
|
||||
model = bound_method.__self__
|
||||
ormcache = bound_method.clear_cache.__self__
|
||||
cache, key0, counter = ormcache.lru(model)
|
||||
key = key0 + ormcache.key(model, *args, **kwargs)
|
||||
return cache, key, counter
|
||||
|
||||
+1
-1
@@ -471,7 +471,7 @@ class profile(object):
|
||||
def wrapper(*args, **kwargs):
|
||||
profile = cProfile.Profile()
|
||||
result = profile.runcall(f, *args, **kwargs)
|
||||
profile.dump_stats(self.fname or ("%s.cprof" % (f.func_name,)))
|
||||
profile.dump_stats(self.fname or ("%s.cprof" % (f.__name__,)))
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user