[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread Paul Sokolovsky
Hello, On Sat, 29 May 2021 17:29:26 -0300 André Roberge wrote: > On Sat, May 29, 2021 at 4:54 PM Irit Katriel > wrote: > > > > > You can control what the traceback of exceptions you are emitting: > > > > "raise e.with_traceback(None)" should clear everything before the > > current frame. > >

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread André Roberge
On Sat, May 29, 2021 at 4:54 PM Irit Katriel wrote: > > You can control what the traceback of exceptions you are emitting: > > "raise e.with_traceback(None)" should clear everything before the current > frame. > I'm sorry, but I still don't see how. This particular line would still show up. Tr

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread Irit Katriel via Python-ideas
You can control what the traceback of exceptions you are emitting: "raise e.with_traceback(None)" should clear everything before the current frame. Or you can get clever and construct a traceback with only the frames you want. On Saturday, May 29, 2021, 08:27:18 PM GMT+1, André Roberge w

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread Thomas Grainger
https://github.com/agronholm/anyio/blob/9eb4671547b01f5e3ba0e0ca602b6aceec15af86/src/anyio/_backends/_asyncio.py#L598 On Sat, 29 May 2021, 20:24 André Roberge, wrote: > > > On Sat, May 29, 2021 at 3:25 PM Thomas Grainger wrote: > >> pytest uses __tracebackhide__ >> >> https://doc.pytest.org/en

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread André Roberge
On Sat, May 29, 2021 at 3:25 PM Thomas Grainger wrote: > pytest uses __tracebackhide__ > > https://doc.pytest.org/en/latest/example/simple.html#writing-well-integrated-assertion-helpers > Thanks for the reminder. Pytest takes care of traceback formatting for users. Individual projects can of

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread André Roberge
On Sat, May 29, 2021 at 3:38 PM Irit Katriel wrote: > See this issue: https://bugs.python.org/issue31299 > > This issue refers to https://bugs.python.org/issue16217 which talks about lines "above" the one of interest (compared with those that I describe as being "below"). It also talks about fi

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread Irit Katriel via Python-ideas
See this issue:  https://bugs.python.org/issue31299 On Saturday, May 29, 2021, 07:19:32 PM GMT+1, André Roberge wrote: With CPython, tracebacks obtained from code written in C can be extremely clean compared with functionally equivalent code written in Python.  Consider the followin

[Python-ideas] Re: Cleaner tracebacks from Python code

2021-05-29 Thread Thomas Grainger
pytest uses __tracebackhide__ https://doc.pytest.org/en/latest/example/simple.html#writing-well-integrated-assertion-helpers Eg anyio sets __tracebackhide__ = __traceback_hide__ = True to remove internal frames from user Tracebacks On Sat, 29 May 2021, 19:21 André Roberge, wrote: > With CPyth