Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
b8a00bf1
Commit
b8a00bf1
authored
Feb 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement traceback.print_stack() and use that to further test generator tracebacks
parent
929e154f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
from_cpython/Lib/traceback.py
from_cpython/Lib/traceback.py
+12
-7
test/tests/generator_tracebacks.py
test/tests/generator_tracebacks.py
+6
-0
No files found.
from_cpython/Lib/traceback.py
View file @
b8a00bf1
...
@@ -293,13 +293,18 @@ def print_stack(f=None, limit=None, file=None):
...
@@ -293,13 +293,18 @@ def print_stack(f=None, limit=None, file=None):
arguments have the same meaning as for print_exception().
arguments have the same meaning as for print_exception().
"""
"""
raise
NotImplementedError
(
"This function is currently not implemented in Pyston"
)
if
f
is
not
None
or
limit
is
not
None
:
if
f
is
None
:
raise
NotImplementedError
(
"print_stack() does not currently support the 'f' or 'limit' arguments in Pyston"
)
try
:
try
:
raise
ZeroDivisionError
raise
ZeroDivisionError
except
ZeroDivisionError
:
except
ZeroDivisionError
:
f
=
sys
.
exc_info
()[
2
].
tb_frame
.
f_back
# Make use of Pyston's incorrect behavior, that we generate exception tracebacks all the
print_list
(
extract_stack
(
f
,
limit
),
file
)
# 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
):
def
format_stack
(
f
=
None
,
limit
=
None
):
"""Shorthand for 'format_list(extract_stack(f, limit))'."""
"""Shorthand for 'format_list(extract_stack(f, limit))'."""
...
...
test/tests/generator_tracebacks.py
View file @
b8a00bf1
# allow-warning: converting unicode literal to str
# Generators participate in the notional Python stack just like normal function calls do,
# Generators participate in the notional Python stack just like normal function calls do,
# even if we implement them using separate C stacks.
# even if we implement them using separate C stacks.
#
#
...
@@ -5,7 +7,10 @@
...
@@ -5,7 +7,10 @@
# get inherited when we go into a generator
# 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:
# exc_info gets passed into generators (at both begin and send()) and cleared like normal on the way out:
import
sys
import
sys
import
traceback
def
f12
():
def
f12
():
print
print
print
"f12"
print
"f12"
...
@@ -19,6 +24,7 @@ def f12():
...
@@ -19,6 +24,7 @@ def f12():
try
:
try
:
raise
KeyError
()
raise
KeyError
()
except
:
except
:
traceback
.
print_stack
(
file
=
sys
.
stdout
)
pass
pass
print
"after KeyError:"
,
sys
.
exc_info
()[
0
]
print
"after KeyError:"
,
sys
.
exc_info
()[
0
]
yield
2
yield
2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment