bugfix: py contains raises errors when appropiate#4209
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
| 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.
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.
@rwgk Good catch, my test designed to test this pathway fired fine without the if statement locally.
rwgk
left a comment
There was a problem hiding this comment.
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. |
henryiii
left a comment
There was a problem hiding this comment.
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: