Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.02k stars 1.71k forks source link

Using Traceback Handler has no effect #3266

Open PhilippFeO opened 8 months ago

PhilippFeO commented 8 months ago

Hey guys,

I setup rich as described in https://rich.readthedocs.io/en/latest/traceback.html but receive the standard python Traceback. I executed all files via python /tmp/rich-test.py after source ~/.venv/rich/bin/activate.

I don't know which pieces you need, so I included everything I found worth mentioning

cat ~/.venv/rich/lib/python3.10/site-packages/sitecustomize.py:

from rich.traceback import install
install(show_locals=True)

Python code to run:

a = 0
print(1/a)

Output:

Traceback (most recent call last):
  File "/tmp/rich-test.py", line 2, in <module>
    print(1/a)
ZeroDivisionError: division by zero

Further examples and information

importing sitecustomize

cat /tmp/rich-test.py

import sitecustomize
print(sitecustomize.__file__)

a = 0
print(1/a)

Output:

/usr/lib/python3.10/sitecustomize.py
Traceback (most recent call last):
  File "/tmp/rich-test.py", line 5, in <module>
    print(1/a)
ZeroDivisionError: division by zero

and output of cat /usr/lib/python3.10/sitecustomize.py:

# install the apport exception handler if available
try:
    import apport_python_hook
except ImportError:
    pass
else:
    apport_python_hook.install()

Using rich directly

~/.venv/rich/lib/python3.10/site-packages/sitecustomize.py from above unchanged.
cat /tmp/rich-test.py:

from rich.traceback import install
install(show_locals=True)

a = 0
print(1/a)

Output: Rich traceback's output.


Any help and hints are welcome! :open_hands: I'll provide you with whatever information you wish. :blush:

github-actions[bot] commented 8 months ago

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory