-
Notifications
You must be signed in to change notification settings - Fork 2.2k
bugfix: py contains raises errors when appropiate #4209
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
Conversation
Will do. |
Hi @mattip, PyPy doesn't seem to raise
|
If I understand correctly, |
Thanks @mattip! I downloaded and unpacked the "log archive" here, then:
AFAICT it only fails for @Skylion007 does my understanding look right to you? |
Right, I can reproduce with a nightly pypy in a repo that runs CI on popular C extensions. I will try to fix it there. |
I don't see any problems in the global testing results related to this PR. Very minor caveat: results are unusually noisy this morning, but I looked pretty carefully. |
There is a corner case for empty sets where PyPy does not raise. CPython2 and CPython3 raise. See https://foss.heptapod.net/pypy/pypy/-/issues/3824 |
include/pybind11/pytypes.h
Outdated
@@ -2349,7 +2357,11 @@ args_proxy object_api<D>::operator*() const { | |||
template <typename D> | |||
template <typename T> | |||
bool object_api<D>::contains(T &&item) const { | |||
return attr("__contains__")(std::forward<T>(item)).template cast<bool>(); | |||
auto ret = attr("__contains__")(std::forward<T>(item)).template cast<bool>(); | |||
if (PyErr_Occurred()) { |
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.
Can this actually happen?
I was thinking the line before will either succeed or there will be an exception (error_already_set
, cast_error
) in flight already.
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.
@rwgk Good catch, my test designed to test this pathway fired fine without the if statement locally.
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.
Thanks Aaron for plugging these holes, and the new tests!
CentOS7 / PGI 22.3 appears to be generally broken (same failure in another PR) and the other failing test is a notorious flake. I think it's best if we ignore the CentoOS failure, merge our PRs, then one of us can look what's going on with CentOS. |
294f720
to
129c6cf
Compare
@Skylion007 I just rebased this on master, to trigger the CI, to see if the CentOS7 / PGI 22.3 problem was fixed in the meantime. |
@henryiii @ax3l Do you know what's behind the error below? First observed yesterday, still failing now. https://github.com/pybind/pybind11/actions/runs/3244896869/jobs/5321695298
|
Hi @Skylion007, is there a chance that you could merge this today? (Asking b/o I'm hoping to include this in the next smart_holder update.) |
@rwgk Wasn't sure if wanted to wait until the next major update as this is a bit of a behavior change. |
If we are good with it, feel free to merge it. |
Do you want this in 2.10.1? It looks more like a bug-fix-behavior-change than a feature-behavior-change to me. |
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.
Yes, I’d say this is a bug fix.
Thanks! |
Only concern is that set.add() is still broken, and we sort of rely on that broken behavior in the caster. So that's a bigger PR issue I haven't looked at. |
Sorry, looks like I was a bit fast.
Leaving that for later sounds like the right move, does that make sense? |
Description
Suggested changelog entry: