mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 19:34:18 -04:00
display instance variables one level deep
This commit is contained in:
parent
b48a493323
commit
37c9bcdb56
@ -60,19 +60,23 @@ def _varDump__print(exc):
|
|||||||
sReentry -= 1
|
sReentry -= 1
|
||||||
|
|
||||||
oldExcepthook = None
|
oldExcepthook = None
|
||||||
# store these values here so that Task.py can always reliably access these values
|
# store these values here so that Task.py can always reliably access them
|
||||||
# from its main exception handler
|
# from its main exception handler
|
||||||
wantVariableDump = False
|
wantVariableDump = False
|
||||||
dumpOnExceptionInit = False
|
dumpOnExceptionInit = False
|
||||||
|
|
||||||
def _excepthookDumpVars(eType, eValue, traceback):
|
class _AttrNotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _excepthookDumpVars(eType, eValue, tb):
|
||||||
s = 'DUMPING STACK FRAME VARIABLES'
|
s = 'DUMPING STACK FRAME VARIABLES'
|
||||||
tb = traceback
|
origTb = tb
|
||||||
#import pdb;pdb.set_trace()
|
#import pdb;pdb.set_trace()
|
||||||
foundRun = False
|
foundRun = False
|
||||||
while tb is not None:
|
while tb is not None:
|
||||||
frame = tb.tb_frame
|
frame = tb.tb_frame
|
||||||
code = frame.f_code
|
code = frame.f_code
|
||||||
|
names = code.co_names
|
||||||
tb = tb.tb_next
|
tb = tb.tb_next
|
||||||
# skip everything before the 'run' method, those frames have lots of
|
# skip everything before the 'run' method, those frames have lots of
|
||||||
# not-useful information
|
# not-useful information
|
||||||
@ -84,13 +88,22 @@ def _excepthookDumpVars(eType, eValue, traceback):
|
|||||||
s += '\n File "%s", line %s, in %s' % (
|
s += '\n File "%s", line %s, in %s' % (
|
||||||
code.co_filename, frame.f_lineno, code.co_name)
|
code.co_filename, frame.f_lineno, code.co_name)
|
||||||
for name, val in frame.f_locals.iteritems():
|
for name, val in frame.f_locals.iteritems():
|
||||||
r = fastRepr(val)
|
r = fastRepr(val, maxLen=10)
|
||||||
if type(r) is types.StringType:
|
if type(r) is types.StringType:
|
||||||
r = r.replace('\n', '\\n')
|
r = r.replace('\n', '\\n')
|
||||||
s += '\n %s=%s' % (name, r)
|
s += '\n %s=%s' % (name, r)
|
||||||
|
# check if we should display any immediate attributes of the object
|
||||||
|
for n in names:
|
||||||
|
a = getattr(val, n, _AttrNotFound)
|
||||||
|
if a is not _AttrNotFound:
|
||||||
|
r = fastRepr(a, maxLen=10)
|
||||||
|
if type(r) is types.StringType:
|
||||||
|
r = r.replace('\n', '\\n')
|
||||||
|
s += '\n %s.%s=%s' % (name, n, r)
|
||||||
|
|
||||||
s += '\n'
|
s += '\n'
|
||||||
notify.info(s)
|
notify.info(s)
|
||||||
oldExcepthook(eType, eValue, traceback)
|
oldExcepthook(eType, eValue, origTb)
|
||||||
|
|
||||||
def install():
|
def install():
|
||||||
global oldExcepthook
|
global oldExcepthook
|
||||||
|
@ -2321,6 +2321,7 @@ def fastRepr(obj, maxLen=200, strFactor=10, _visitedIds=None):
|
|||||||
return safeRepr(obj)
|
return safeRepr(obj)
|
||||||
else:
|
else:
|
||||||
r = safeRepr(obj)
|
r = safeRepr(obj)
|
||||||
|
maxLen *= strFactor
|
||||||
if len(r) > maxLen:
|
if len(r) > maxLen:
|
||||||
r = r[:maxLen]
|
r = r[:maxLen]
|
||||||
return r
|
return r
|
||||||
|
Loading…
x
Reference in New Issue
Block a user