Skip to content

Commit

Permalink
Move 7.3.8 warning over to make_module
Browse files Browse the repository at this point in the history
  • Loading branch information
mejrs committed Apr 13, 2022
1 parent bf3d7a0 commit 97230d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,6 @@ where
let unwind_safe_py = AssertUnwindSafe(pool.python());
let panic_result = panic::catch_unwind(move || -> PyResult<_> {
let py = *unwind_safe_py;
#[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.compare(crate::types::PyTuple::new(py, &PYPY_GOOD_VERSION))?
== std::cmp::Ordering::Less
{
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.",
))?;
}
}
body(py)
});

Expand Down
18 changes: 18 additions & 0 deletions src/derive_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,24 @@ impl ModuleDef {
py: Python,
initializer: impl Fn(Python, &PyModule) -> PyResult<()>,
) -> PyResult<*mut ffi::PyObject> {
#[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.compare(crate::types::PyTuple::new(py, &PYPY_GOOD_VERSION))?
== std::cmp::Ordering::Less
{
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.",
))?;
}
}

let module =
unsafe { py.from_owned_ptr_or_err::<PyModule>(ffi::PyModule_Create(self.0.get()))? };
initializer(py, module)?;
Expand Down

0 comments on commit 97230d1

Please sign in to comment.