本文整理汇总了Python中traceback.walk_stack函数的典型用法代码示例。如果您正苦于以下问题:Python walk_stack函数的具体用法?Python walk_stack怎么用?Python walk_stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了walk_stack函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_walk_stack
def test_walk_stack(self):
def deeper():
return list(traceback.walk_stack(None))
s1 = list(traceback.walk_stack(None))
s2 = deeper()
self.assertEqual(len(s2) - len(s1), 1)
self.assertEqual(s2[1:], s1)
示例2: extract_stack
def extract_stack(f=None, limit=None):
"""Replacement for traceback.extract_stack() that only does the
necessary work for asyncio debug mode.
"""
if f is None:
f = sys._getframe().f_back
if limit is None:
# Limit the amount of work to a reasonable amount, as extract_stack()
# can be called for each coroutine and future in debug mode.
limit = constants.DEBUG_STACK_DEPTH
stack = traceback.StackSummary.extract(traceback.walk_stack(f),
limit=limit,
lookup_lines=False)
stack.reverse()
return stack
示例3: f
def f():
summary = traceback.StackSummary.extract(
traceback.walk_stack(None)
)
print(''.join(summary.format()))
示例4: some_inner
def some_inner(k, v):
a = 1
b = 2
return traceback.StackSummary.extract(
traceback.walk_stack(None), capture_locals=True, limit=1)
示例5: test_extract_stack_limit
def test_extract_stack_limit(self):
s = traceback.StackSummary.extract(traceback.walk_stack(None), limit=5)
self.assertEqual(len(s), 5)
示例6: test_extract_stack
def test_extract_stack(self):
s = traceback.StackSummary.extract(traceback.walk_stack(None))
self.assertIsInstance(s, traceback.StackSummary)
示例7: test_walk_stack
def test_walk_stack(self):
s = list(traceback.walk_stack(None))
self.assertGreater(len(s), 10)
示例8: f
def f():
summary = traceback.StackSummary.extract(
traceback.walk_stack(None)
)
for fs in summary:
print(template.format(fs=fs))
示例9: deeper
def deeper():
return list(traceback.walk_stack(None))