-
Notifications
You must be signed in to change notification settings - Fork 591
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
Elide internal frames from tracebacks, to focus on user code #1582
Conversation
c9d62ae
to
a72bd2c
Compare
|
a1efe06
to
8db1d00
Compare
8db1d00
to
87ecd86
Compare
On Python 2 you might be able to make it work by using 3-argument But I'm not sure it's worth bothering, since it's, y'know, python 2. I hadn't realized that hypothesis has a |
Yuck, three-argument Definitely keen to join the multi-exception conversation; and eventually to use the standard exception type like everyone else. I've even been quietly subscribed to the Trio issue for a while 😄 |
87ecd86
to
5619872
Compare
...on the other hand, it turns out that the |
5619872
to
09d4e28
Compare
@@ -931,7 +933,18 @@ def wrapped_test(*arguments, **kwargs): | |||
report( | |||
'You can add @seed(%d) to this test to ' | |||
'reproduce this failure.' % (generated_seed,)) | |||
raise | |||
if PY2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I have a very strong preference against if PY2
code outside of compat.py
. Can this not be refactored to a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not without adding another stack frame, and we've just gone to a fair bit of trouble to get rid of those! Worse, we'd have that extra frame on all Python 3 as well 😭
Otherwise it absolutely would be compat.raise_with_traceback(error, tb)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Could you add an explanatory comment to the code then, please?
(In general I think this section could use some fairly verbose commenting because even knowing what it's supposed to do I'm finding it a bit eyebrow raising)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, comments incoming. I'll also try to refactor things a bit so the logic is as clear as possible without comments too!
c3841f2
to
faac53e
Compare
faac53e
to
f41e2d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to expand the scope slightly but... I think this needs a flag of some sort to turn it off, e if .g. an internal use environment variable. Otherwise it has the potential to be very annoying for us when debugging things going wrong.
hypothesis-python/RELEASE.rst
Outdated
@@ -0,0 +1,9 @@ | |||
RELEASE_TYPE: patch | |||
|
|||
This patch stops Hypothesis from leaking implementation details - each |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure "letting tracebacks behave like they normally do" counts as leaking information details.
It carefully checks, and will not change any traceback raised from a Hypothesis file unless the exception is a |
f2878ac
to
7fc1a84
Compare
🎉 I'm going to wait for the ongoing GitHub incident to be fully resolved, then rebase on master before merging to avoid any conflicts or build/deploy errors. But soon! |
7fc1a84
to
1d93306
Compare
Closes #848, with an approach adapted from
trio
.Basically we just strip frames off the traceback until we reach one that did not come from a Hypothesis file, attach the shortened traceback to the exception, and raise it. Then our
@proxies
decorator overwrites the frame location so it doesn't look like a Hypothesis file... so there's a cute trick where we inject an entry into the frame globals and check for that too when unwinding.comparison of old and new output from pytest
Here's a very simple test suite:
After this change, here's the output from pytest:
While here's what it looked like before: