def do_environment(self):
"return current frame local and global environment"
env = {'locals': {}, 'globals': {}}
# converts the frame global and locals to a short text representation:
if self.frame:
for scope, max_length, vars in (
("locals", 255, list(self.frame_locals.items())),
("globals", 20, list(self.frame.f_globals.items())), ):
for (name, value) in vars:
try:
short_repr = pydoc.cram(repr(value), max_length)
except Exception as e:
# some objects cannot be represented...
short_repr = "**exception** %s" % repr(e)
env[scope][name] = (short_repr, repr(type(value)))
return env
评论列表
文章目录