Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
e8487ea1
Commit
e8487ea1
authored
Dec 10, 2014
by
Paul Sokolovsky
Committed by
Damien George
Dec 10, 2014
Browse files
tests: Add test for print_exception() function.
parent
6c3fc746
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/misc/print_exception.py
0 → 100644
View file @
e8487ea1
import
io
import
sys
if
hasattr
(
sys
,
'print_exception'
):
print_exception
=
sys
.
print_exception
else
:
import
traceback
print_exception
=
lambda
e
,
f
:
traceback
.
print_exception
(
None
,
e
,
None
,
file
=
f
)
try
:
1
/
0
except
Exception
as
e
:
print
(
'caught'
)
buf
=
io
.
StringIO
()
print_exception
(
e
,
buf
)
s
=
buf
.
getvalue
()
for
l
in
s
.
split
(
"
\n
"
):
# uPy and CPy tracebacks differ in that CPy prints a source line for
# each traceback entry. In this case, we know that offending line
# has 4-space indent, so filter it out.
if
not
l
.
startswith
(
" "
):
print
(
l
)
Write
Preview
Supports
Markdown
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