Skip to content

Commit

Permalink
fix: minor cleanup, try pypy again
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Nov 16, 2021
1 parent 60cee13 commit 0618bd5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ jobs:
- '3.6'
- '3.9'
- '3.10'
# - '3.11-dev'
- 'pypy-3.7-v7.3.5'
#- 'pypy-3.8-v7.3.7'
- 'pypy-3.7-v7.3.7'
- 'pypy-3.8-v7.3.7'

# Items in here will either be added to the build matrix (if not
# present), or add new keys to an existing matrix element if all the
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -2367,7 +2367,7 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
Unfortunately this doesn't work on PyPy. */
#if !defined(PYPY_VERSION) && PY_VERSION_HEX < 0x030B0000
// TODO: Remove PyPy workaround for Python 3.11.
// Current API fails on 3.11 since covarnames can be null.
// Current API fails on 3.11 since co_varnames can be null.
#if PY_VERSION_HEX >= 0x03090000
PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());
if (frame != nullptr) {
Expand Down
6 changes: 4 additions & 2 deletions tests/test_buffers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def test_from_python():


# https://foss.heptapod.net/pypy/pypy/-/issues/2444
# TODO: fix on recent PyPy
@pytest.mark.xfail(
env.PYPY, reason="PyPy 7.3.7 doesn't clear this anymore", stict=False
)
def test_to_python():
mat = m.Matrix(5, 4)
assert memoryview(mat).shape == (5, 4)
Expand All @@ -62,8 +66,6 @@ def test_to_python():
assert cstats.alive() == 1
del mat2 # holds a mat reference
pytest.gc_collect()
pytest.gc_collect() # Needed for PyPy
pytest.gc_collect() # Needed for PyPy
assert cstats.alive() == 0
assert cstats.values() == ["5x4 matrix"]
assert cstats.copy_constructions == 0
Expand Down
3 changes: 3 additions & 0 deletions tests/test_builtin_casters.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def cant_convert(v):
assert noconvert(7) == 7
cant_convert(3.14159)
# TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
# TODO: PyPy 3.8 does not behave like CPython 3.8 here yet (7.3.7)
if (3, 8) <= env.PY < (3, 10) and env.CPYTHON:
with env.deprecated_call():
assert convert(Int()) == 42
Expand Down Expand Up @@ -334,6 +335,8 @@ def require_implicit(v):

# The implicit conversion from np.float32 is undesirable but currently accepted.
# TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
# TODO: PyPy 3.8 does not behave like CPython 3.8 here yet (7.3.7)
# https://github.com/pybind/pybind11/issues/3408
if (3, 8) <= env.PY < (3, 10) and env.CPYTHON:
with env.deprecated_call():
assert convert(np.float32(3.14159)) == 3
Expand Down
5 changes: 3 additions & 2 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

import env # noqa: F401
import env
import pybind11_cross_module_tests as cm
from pybind11_tests import exceptions as m

Expand Down Expand Up @@ -97,6 +97,8 @@ def ignore_pytest_unraisable_warning(f):
return f


# TODO: find out why this fails on PyPy, https://foss.heptapod.net/pypy/pypy/-/issues/3583
@pytest.mark.xfail(env.PYPY, reason="Failure on PyPy 3.8 (7.3.7)", strict=False)
@ignore_pytest_unraisable_warning
def test_python_alreadyset_in_destructor(monkeypatch, capsys):
hooked = False
Expand All @@ -109,7 +111,6 @@ def test_python_alreadyset_in_destructor(monkeypatch, capsys):

def hook(unraisable_hook_args):
exc_type, exc_value, exc_tb, err_msg, obj = unraisable_hook_args
print(locals())
if obj == "already_set demo":
triggered[0] = True
default_hook(unraisable_hook_args)
Expand Down

0 comments on commit 0618bd5

Please sign in to comment.