-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-70186: Fix doctest badly handling unwrapable objects #14756
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
base: main
Are you sure you want to change the base?
Conversation
cc @bitdancer (R. David Murray), @stevendaprano |
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 significantly more in favor of raising an explicit exception message from the doctests. The usage of:
try:
...
except Exception:
return False
is generally frowned upon, as far as I'm aware.
Also, thanks for the contribution! |
@aeros167 Changes done 👍 |
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.
Looks good as far as I can tell, thanks for making the suggested changes. Since there's no active core dev expert on the doctests in the expert index I'll mention some others. Three of them are listed as other test experts and vstinner is experienced with writing tests in general.
LGTM. Can you resolve the merge conflict? @BoboTiG |
I fixed conflicts, but it seems doctest source code has changed since 2019 :) |
89c79fd
to
0e5672d
Compare
I finally got time to update the patch, and the CI is still green 🎉 /cc @aeros @furkanonder |
@BoboTiG shall we land this :) ? |
It's up to the team, the CI is green :) |
[EuroPython 2019]
For some reason, an object could raise an error different from
AttributeError
when checking for its__wrapped__
attribute.This patch silences any errors coming from the underlying call to
inpect.unwrap()
and, ifverbose
is set toTrue
, prints out the exception.Thanks to @mpaolini for helping me with the reproduction test case.
As of the current patch state, I followed R. David Murray (I do not find his GH nick) sentence from his last comment on the BPO:
Another solution would be to patch
inspect.unwrap()
like:But we then loose details and nobody could know that there is an issue somewhere.
I did not want to raise a specific error from there only for doctest (but it is still totally doable).
Yet another solution would to raise from doctest instead of printing. Such as:
As it is done few lines below when doctest cannot deal with certain objects or certains conditions.
This would keep some uniformization in how doctest handle bad cases.
👀 I need external eyes to decide on what is the best solution to use :) (I had to leave the sprints before having time to speak with a core dev)
https://bugs.python.org/issue25998