-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG]: tracking issue for PyPy 7.3.6 support (PyPy 3.8) #3408
Comments
The now-failing test links to https://foss.heptapod.net/pypy/pypy/-/issues/2444 (CC @mattip), but instead of working, it now seems to be leaking, perhaps? Since this runs on both CPython and PyPY, I'm assuming the test was working before, even though it has an issue at the top. pybind11/tests/test_buffers.py Lines 38 to 70 in d45a881
For the two tests not producing warnings for int conversion, I think that's a difference in implementation (but needs to be checked, CC @YannickJadoul. pybind11/tests/test_builtin_casters.py Lines 335 to 342 in d45a881
For pybind11/include/pybind11/eval.h Lines 21 to 32 in d45a881
Looks like the block patching in the hook in 3.8 doesn't work in PyPy 3.8. pybind11/tests/test_exceptions.py Lines 102 to 122 in d45a881
|
It would be good to track this down, since that issue is closed. We yet again modified buffer handling for PyPy3.8 and maybe missed something. With that, the implementation of pytest.gc_collect() calls gc.collect() twice. In NumPy's implementation, I needed 3 calls.
Do you know where/how this change happened? I don't see it documented for PyRun_String nor in the 3.8 changelog. Maybe this is not 3.8-specific or is it more general to all invocations of For |
#2616 points at python/cpython#13362, the implementation of PEP 587. |
For |
I think that might have been on PyPy3.7, |
I think it's there, but it doesn't work. The code path does trigger to set it, but it doesn't do anything. |
Strange. |
I'm rerunning it (as part of something else) in #3419 - I'll see if I can see what part is failing. |
Interesting, for failure 1, that happens on PyPy3.7 7.3.7 as well (wow that's a lot of threes and sevens). So it's a change with all PyPy, not just the 3.8 branch. It used to behave more like CPython, and now isn't - though like anything related to the garbage collector, I'm not sure it's so critical. I'll try multiple calls, which I think is what was suggested above. |
Another PyPy 3.8 issue: Before Python 3.8, Also, there's a missing I see difference between PyPy and CPython's |
We can (and do) backport that behavior for 3.7 and before, but it should be supported by PyPy3.8 directly, I think. |
It is a bit hard to manage all this in a github issue conversation. Can you point to the failing tests? |
Sure, ignore the failing Python 3.11 tests, I'm enabling 3.11 and the new PyPy in the same PR for testing, #3419. If you scroll to the bottom of https://github.com/pybind/pybind11/pull/3419/files, you can see the failures annotated in place. PyPy 3.7: PyPy 3.8: The
I'm ignoring the float conversion lack-of-warnings for now. |
Here's an old workaround for the difference in pybind11/include/pybind11/cast.h Lines 135 to 141 in a80b223
But I don't think that affects anything we are seeing here. This is the block implementing the Python 3.8 behavior for all versions of Python for long conversion: pybind11/include/pybind11/cast.h Lines 153 to 174 in a80b223
And I think this is also where CPython 3.8-3.9 produce a DeprecationWarning, while PyPy does not, if you call |
Ahh, so the difference is |
If you call |
Thanks. This part was not done for PyPy.
|
I've downloaded PyPy 3.8 via the web to test locally and can't really use it because I'm getting spammed with "Cannot be opened because the developer cannot be verified" for every |
I assume you are on macOS. There are guides somewhere about marking the file as "allowed". Is it up on homebrew? One trick that used to work is to download it via curl or wget and not via a browser. |
I can try wget. Homebrew is just now updating to 7.3.7 (as in it's available now but not when I sent the last message), but |
So the current status:
Garbage collector buffer test:
|
Where is the value |
It's from this call: pybind11/tests/test_exceptions.py Line 120 in c8ce4b8
Which triggers this call with the given string object as pybind11/tests/test_exceptions.cpp Line 101 in a80b223
Which triggers this CAPI: pybind11/include/pybind11/pytypes.h Lines 361 to 364 in a80b223
|
I'd guess it triggers this in PyPy, which looks fine to me: |
And this is my first attempt at a MWE, but it seems to work identically in python and pypy3.8: import sys
import gc
triggered = [False] # mutable
default_hook = sys.__unraisablehook__
class Unraisable:
def __del__(self):
raise Exception("demo")
def hook(unraisable_hook_args):
exc_type, exc_value, exc_tb, err_msg, obj = unraisable_hook_args
if obj == Unraisable.__del__:
triggered[0] = True
default_hook(unraisable_hook_args)
return
sys.unraisablehook = hook
def demo():
x = Unraisable()
del x
gc.collect()
demo()
assert triggered[0], "This printout should not be shown" Might need CAPI to go further, unless there's a way to get at this more easily. |
How critical is this problem? |
Not very. It's just nice to have as much parity as possible between CPython and PyPy, and the less we have to work around, the better it is for other users too. But I can ignore the remaining tests on PyPy, ping the author of the unraisable code to see if it's worth a caveat in the docs, and go forward. The danger is that makes it easy to forget. :/ |
There are so many things to work on, I don't want to get bogged down in this corner case.
Sure, an issue on the pypy tracker would prevent that. |
Here is a new failure. I think it can be described as: calling
|
This is fixed on latest pypy3.8 nightlies. |
I tried a little test and this seemed to be fine. diff --git a/noxfile.py b/noxfile.py
index 4adffac2..3eedd455 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -2,7 +2,7 @@ import nox
nox.options.sessions = ["lint", "tests", "tests_packaging"]
-PYTHON_VERISONS = ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
+PYTHON_VERISONS = ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.7"]
@nox.session(reuse_venv=True)
diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp
index bc5c6553..ce2953fd 100644
--- a/tests/test_stl.cpp
+++ b/tests/test_stl.cpp
@@ -522,4 +522,7 @@ TEST_SUBMODULE(stl, m) {
[]() { return new std::vector<bool>(4513); },
// Without explicitly specifying `take_ownership`, this function leaks.
py::return_value_policy::take_ownership);
+
+ // Test list printing
+ m.def("print_as_list", [](const py::object &any){std::cout << py::cast<py::list>(any);});
}
diff --git a/tests/test_stl.py b/tests/test_stl.py
index e2179759..d939ce4f 100644
--- a/tests/test_stl.py
+++ b/tests/test_stl.py
@@ -356,3 +356,14 @@ def test_return_vector_bool_raw_ptr():
v = m.return_vector_bool_raw_ptr()
assert isinstance(v, list)
assert len(v) == 4513
+
+
+def test_print_list(capsys):
+ m.print_as_list([])
+
+ class A:
+ pass
+
+ m.print_as_list([A()])
+
+ assert False This spits out |
Maybe there is some subtle difference between |
There shouldn't be, but just I tried that anyway, same results. Does the same thing happen if you do |
Unrelated: @mattip could PyPy binaries for macOS please be built with 10.9+ instead of 10.7+ compatibility like the CPython binaries? Setting 10.7 means that these are broken out-of-the box when trying to build, since 10.9 was the first macOS version to use libc++, and libstdc++ was removed a few years ago, meaning targeting anything less than 10.9 is broken on modern macOS's. And the extension default is to match what the Python binaries target, and they target 10.7. |
Do you know which PR bumped it? |
It used to be 10.6 when they provided FAT binaries, before they went to 64 bit only, that's when they became 10.9+ only. It's never been 10.7, IIRC pypy needed 10.7 instead of 10.6 for some reason. But you really, really want to be 10.9, due to the change to libc++. I can't get See https://www.python.org/downloads/release/python-365/ -> macOS users, and this was also backported to 2.7 (but not 3.5, which had already finished binary releases). Python 3.8.0 was the first to remove the old 32/64 binary format entirely. |
Also, it seems like PyPy is burning in 10.7 regardless of the OS it was built on when nothing is set. While Python defaults to the current OS version, and only the distributed binaries have older versions set. This means homebrew python, conda-forge python, etc. all have a much higher OS version than the official binaries, which is why we only use the official binaries for building wheels in cibuildwheel. But it also means that users trying to build code locally aren't having to worry about old compatibility issues like limited C++17 support (unless they download the official binaries, which many macOS users do not do). |
Does PyPy from conda-forge/homebrew also pin to 10.7? |
Sorry, I am not really fluent in macOS. What is wrong and what would the fix look like? I didn't understand the rest of the comment. |
|
@henryiii PyPy has somewhat redone its macOS builds to accomodate arm64 builds. Do the nightlies (py3.8, py3.9) work any better now? |
Required prerequisites
Problem description
We are having issues with the PyPy update, so I'm going to avoid making it and just list the problems here, eventually opening up another PR (currently mixed into #3368). This will also focus only on supporting it, not on building binaries with it, which is a bad idea (on PyPy3.7, anyway) - users should wait till 7.3.7 to build binaries (and existing ones like possibly NumPy won't work).
For both 3.7 and 3.8:
test_to_python
returns 1 fromcstats.alive()
For 3.8 Unix:
test_int_convert
does not produce a warning (was not included before)test_numpy_int_convert
does not produce a warning (Also was not included before)PyLong_AsLong
implementation does not contain the updates made in CPython to call__index__
.test_eval_empty_globals
does not contain__builtins__
(or anything).test_python_alreadyset_in_destructor
returns False fromtriggered[0]
For 3.8 Windows:
ImportError: initialization failed
. Probably from the issue we've always had on 3.8 not being able to run the cross module tests on Windows.For 2.7 macOS:
It seems the parallel setuptools_helpers test hangs. Could be intermittent, a CI issue, or something else, but could be related to PyPy 7.3.6. Edit: rerunning made it pass.
The text was updated successfully, but these errors were encountered: