namer/trace_back: behave on None code_context
This commit is contained in:
parent
e9be3241f6
commit
039c6d8eb4
|
@ -16,13 +16,13 @@ def trace_back(name=None):
|
||||||
obj = modules[len(modules)-1]
|
obj = modules[len(modules)-1]
|
||||||
|
|
||||||
if name is None:
|
if name is None:
|
||||||
line = inspect.getframeinfo(frame).code_context[0]
|
code_contexts = inspect.getframeinfo(frame).code_context
|
||||||
m = re.match("[\t ]*([0-9A-Za-z_\.]+)[\t ]*=", line)
|
if code_contexts is not None:
|
||||||
if m is None:
|
line = code_contexts[0]
|
||||||
name = None
|
m = re.match("[\t ]*([0-9A-Za-z_\.]+)[\t ]*=", line)
|
||||||
else:
|
if m is not None:
|
||||||
names = m.group(1).split(".")
|
names = m.group(1).split(".")
|
||||||
name = names[len(names)-1]
|
name = names[len(names)-1]
|
||||||
l.insert(0, (obj, name))
|
l.insert(0, (obj, name))
|
||||||
name = None
|
name = None
|
||||||
frame = frame.f_back
|
frame = frame.f_back
|
||||||
|
|
Loading…
Reference in New Issue