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

When rendering exceptions, __suppress_context__ is not respected #454

Open
abn opened this issue Nov 25, 2024 · 0 comments
Open

When rendering exceptions, __suppress_context__ is not respected #454

abn opened this issue Nov 25, 2024 · 0 comments
Milestone

Comments

@abn
Copy link
Member

abn commented Nov 25, 2024

Originally identified in python-poetry/poetry#9870.

from cleo.io.buffered_io import BufferedIO
from cleo.ui.exception_trace import ExceptionTrace
from crashtest.inspector import Inspector

if __name__ == "__main__":
    io = BufferedIO()

    try:
        try:
            raise ValueError("ValueError")
        except ValueError:
            raise RuntimeError("RuntimeError") from None
    except Exception as e:
        # assert the condition
        assert e.__context__ is not None
        assert e.__suppress_context__

        # this is the high level impact
        ExceptionTrace(e).render(io)

        # this is the root cause
        assert not Inspector(e).has_previous_exception()
    finally:
        output = io.fetch_output()
        print(output)

        # if __suppress_context__ is respected this should not be displayed
        assert "The following error occurred when trying to handle this error:" not in output
@abn abn changed the title When rendering exceptions __suppress_context__ is not respected When rendering exceptions, __suppress_context__ is not respected Nov 25, 2024
@Secrus Secrus added this to the 3.0 milestone Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants