Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom traceback is being overridden when importing exceptiongroup #96

Open
Tsimopak opened this issue Nov 21, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@Tsimopak
Copy link

Tsimopak commented Nov 21, 2023

I took as a reference the source code of exceptiongroup in order to make a custom exception of my own with a custom traceback .

It worked as expected, the thing is, when I import exceptiongroup, it overrides the traceback exception from the exceptiongroup.

Is there a way to isolate my implementation?

I assume it relates to this code:

traceback_exception_original_format = traceback.TracebackException.format
traceback_exception_original_format_exception_only = (
traceback.TracebackException.format_exception_only
)
traceback_exception_format_syntax_error = getattr(
traceback.TracebackException, "_format_syntax_error", None
)
if sys.excepthook is sys.__excepthook__:
traceback.TracebackException.__init__ = ( # type: ignore[assignment]
PatchedTracebackException.__init__
)
traceback.TracebackException.format = ( # type: ignore[assignment]
PatchedTracebackException.format
)
traceback.TracebackException.format_exception_only = ( # type: ignore[assignment]
PatchedTracebackException.format_exception_only
)
sys.excepthook = exceptiongroup_excepthook

What can I do about it?

@Tsimopak Tsimopak added the enhancement New feature or request label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant