From 88cd9152b20ea886fb6812a17e78600065da89d8 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 8 Mar 2022 20:57:25 +0000 Subject: [PATCH] pypy: support 7.3.8 --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 6 ++++++ pyo3-ffi/src/datetime.rs | 3 --- src/ffi/tests.rs | 1 - src/impl_/pymodule.rs | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22474ba93b8..224c7c02cd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: "3.9", "3.10", "3.11-dev", - "pypy-3.7-v7.3.7", + "pypy-3.7", "pypy-3.8", "pypy-3.9" ] @@ -113,7 +113,7 @@ jobs: ] exclude: # PyPy doesn't release 32-bit Windows builds any more - - python-version: pypy-3.7-v7.3.7 + - python-version: pypy-3.7 platform: { os: "windows-latest", python-architecture: "x86" } - python-version: pypy-3.8 platform: { os: "windows-latest", python-architecture: "x86" } diff --git a/CHANGELOG.md b/CHANGELOG.md index dd360e8ef0e..eb2a5737ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ PyO3 versions, please see the [migration guide](https://pyo3.rs/latest/migration The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Packaging + +- Warn when modules are imported on PyPy 3.7 versions older than PyPy 7.3.8, as they are known to have binary compatibility issues. [#2217](https://github.com/PyO3/pyo3/pull/2217) + ## [0.16.1] - 2022-03-05 ### Packaging diff --git a/pyo3-ffi/src/datetime.rs b/pyo3-ffi/src/datetime.rs index d64996327d6..5e064ea2011 100644 --- a/pyo3-ffi/src/datetime.rs +++ b/pyo3-ffi/src/datetime.rs @@ -359,7 +359,6 @@ pub struct PyDateTime_CAPI { pub TimeType: *mut PyTypeObject, pub DeltaType: *mut PyTypeObject, pub TZInfoType: *mut PyTypeObject, - #[cfg(not(all(PyPy, not(Py_3_8))))] pub TimeZone_UTC: *mut PyObject, pub Date_FromDate: unsafe extern "C" fn( year: c_int, @@ -393,7 +392,6 @@ pub struct PyDateTime_CAPI { normalize: c_int, cls: *mut PyTypeObject, ) -> *mut PyObject, - #[cfg(not(all(PyPy, not(Py_3_8))))] pub TimeZone_FromTimeZone: unsafe extern "C" fn(offset: *mut PyObject, name: *mut PyObject) -> *mut PyObject, @@ -442,7 +440,6 @@ pub unsafe fn PyDateTimeAPI() -> *mut PyDateTime_CAPI { *PyDateTimeAPI_impl.0.get() } -#[cfg(not(all(PyPy, not(Py_3_8))))] #[inline] pub unsafe fn PyDateTime_TimeZone_UTC() -> *mut PyObject { (*PyDateTimeAPI()).TimeZone_UTC diff --git a/src/ffi/tests.rs b/src/ffi/tests.rs index 15b1eb3623b..aa5235210c2 100644 --- a/src/ffi/tests.rs +++ b/src/ffi/tests.rs @@ -41,7 +41,6 @@ fn test_date_fromtimestamp() { } #[test] -#[cfg(not(all(PyPy, not(Py_3_8))))] fn test_utc_timezone() { Python::with_gil(|py| { let utc_timezone = unsafe { diff --git a/src/impl_/pymodule.rs b/src/impl_/pymodule.rs index c9a84cc905e..c88f313c67e 100644 --- a/src/impl_/pymodule.rs +++ b/src/impl_/pymodule.rs @@ -71,6 +71,21 @@ impl ModuleDef { panic_result_into_callback_output( py, std::panic::catch_unwind(move || -> PyResult<_> { + #[cfg(all(PyPy, not(Py_3_8)))] + { + const PYPY_GOOD_VERSION: [u8; 3] = [7, 3, 8]; + let version = py + .import("sys")? + .getattr("implementation")? + .getattr("version")?; + if version.lt(crate::types::PyTuple::new(py, &PYPY_GOOD_VERSION))? { + let warn = py.import("warnings")?.getattr("warn")?; + warn.call1(( + "PyPy 3.7 versions older than 7.3.8 are known to have binary \ + compatibility issues which may cause segfaults. Please upgrade.", + ))?; + } + } Ok(unwind_safe_self.make_module(py)?.into_ptr()) }), )