%%python prints traceback, no exception name or value
See original GitHub issue%%python
def foo(x, y):
return x / y
foo(1, 0)
in a metakernel_bash notebook shows a traceback, but doesn’t include the exception name and value:
File "/Users/parente/miniconda3/envs/spylon-kernel-dev/lib/python3.6/site-packages/metakernel/magics/python_magic.py", line 25, in exec_code
exec(code, globals())
File "<string>", line 4, in <module>
File "<string>", line 2, in foo
I know the exception name and description are available because running the function that does the exec
for the python magic like so:
from metakernel.magics import python_magic
z = python_magic.exec_code('''
def foo(x, y):
return x / y
foo(1, 0)
''', globals(), None)
print(z.ename) # 'ZeroDivisionError'
print(z.evalue) # ('division by zero',)
shows the ename
and evalue
attributes include the additional information that is missing from the magic’s default output of the traceback alone.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
traceback — Print or retrieve a stack traceback — Python 3.11 ...
Format the exception part of a traceback using an exception value such as given by sys.last_value . The return value is a list...
Read more >How to catch and print the full exception traceback without ...
Assigning the traceback return value to a local variable in a function that is handling an exception will cause a circular reference.
Read more >Understanding the Python Traceback
In the above traceback, the exception was a NameError , which means that there is a reference to some name (variable, function, class)...
Read more >How to print exception stack trace in Python? - GeeksforGeeks
This method prints exception information and stack trace entries from traceback object tb to file. Parameters: This method accepts the ...
Read more >traceback – Extract, format, and print exceptions and stack ...
A traceback is a stack trace from the point of an exception handler down the call chain to the point where the exception...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ha! I didn’t even notice the dupe output when I posted. Thanks for the fix (x2).
I’m looking into this… appears to be a change upstream in jupyter api…