Commit b8a00bf1 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Implement traceback.print_stack() and use that to further test generator tracebacks

parent 929e154f
......@@ -293,13 +293,18 @@ def print_stack(f=None, limit=None, file=None):
arguments have the same meaning as for print_exception().
"""
raise NotImplementedError("This function is currently not implemented in Pyston")
if f is None:
if f is not None or limit is not None:
raise NotImplementedError("print_stack() does not currently support the 'f' or 'limit' arguments in Pyston")
try:
raise ZeroDivisionError
except ZeroDivisionError:
f = sys.exc_info()[2].tb_frame.f_back
print_list(extract_stack(f, limit), file)
# Make use of Pyston's incorrect behavior, that we generate exception tracebacks all the
# way to the top stack frame:
l = format_exception(*sys.exc_info())[1:-2]
for s in l:
_print(file, s, '')
def format_stack(f=None, limit=None):
"""Shorthand for 'format_list(extract_stack(f, limit))'."""
......
# allow-warning: converting unicode literal to str
# Generators participate in the notional Python stack just like normal function calls do,
# even if we implement them using separate C stacks.
#
......@@ -5,7 +7,10 @@
# get inherited when we go into a generator
# exc_info gets passed into generators (at both begin and send()) and cleared like normal on the way out:
import sys
import traceback
def f12():
print
print "f12"
......@@ -19,6 +24,7 @@ def f12():
try:
raise KeyError()
except:
traceback.print_stack(file=sys.stdout)
pass
print "after KeyError:", sys.exc_info()[0]
yield 2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment