Skip to content

Document how to print an exceptiongroup traceback when the monkey patching doesn't work / is not applied. #14

@matmel

Description

@matmel

First, thanks for working on this project.

I updated to the latest cattr 22.1.0 from @Tinche who started to use the exceptiongroup backport to report various errors occurring while "structuring" objects. All fine.

Unfortunately, I think I have an installed package that messes with the monkeypatching of the traceback formatting so when I run my buggy object structuring which fails, I get this console output:

Traceback (most recent call last):
  File "debug.py", line 40, in <module>
    main()
  File "debug.py", line 34, in main
    pressure_rule_structured = DATA_QUALITY_CONVERTER.structure(
  File "/opt/python3toolbox/.venv/lib/python3.8/site-packages/cattrs/converters.py", line 281, in structure
    return self._structure_func.dispatch(cl)(obj, cl)
  File "<cattrs generated structure DataQuality.rule_objects.RangeConfig>", line 44, in structure_RangeConfig
cattrs.errors.ClassValidationError: While structuring RangeConfig (4 sub-exceptions)

When I run this same code in an virtualenv with less packages, I get the traceback "trees" akin to the ones shown here: python-attrs/cattrs#258 (comment)

I tried for some time to try to force the exceptiongroup exception formatting and it resulted in different form attribute errors or the likes deep in the exceptiongroup code which makes me think there are 2 monkey patching at play.

My question: is there anyway to force the display of this exceptiongroup formatting even if someone else elsewhere monkeypatched traceback.TracebackException? All my incantations involving traceback stdlib module and exceptiongroup._formatting failed miserably.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions