Skip to content

Commit 97230d1

Browse files
committed
Move 7.3.8 warning over to make_module
1 parent bf3d7a0 commit 97230d1

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/callback.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,23 +244,6 @@ where
244244
let unwind_safe_py = AssertUnwindSafe(pool.python());
245245
let panic_result = panic::catch_unwind(move || -> PyResult<_> {
246246
let py = *unwind_safe_py;
247-
#[cfg(all(PyPy, not(Py_3_8)))]
248-
{
249-
const PYPY_GOOD_VERSION: [u8; 3] = [7, 3, 8];
250-
let version = py
251-
.import("sys")?
252-
.getattr("implementation")?
253-
.getattr("version")?;
254-
if version.compare(crate::types::PyTuple::new(py, &PYPY_GOOD_VERSION))?
255-
== std::cmp::Ordering::Less
256-
{
257-
let warn = py.import("warnings")?.getattr("warn")?;
258-
warn.call1((
259-
"PyPy 3.7 versions older than 7.3.8 are known to have binary \
260-
compatibility issues which may cause segfaults. Please upgrade.",
261-
))?;
262-
}
263-
}
264247
body(py)
265248
});
266249

src/derive_utils.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,24 @@ impl ModuleDef {
319319
py: Python,
320320
initializer: impl Fn(Python, &PyModule) -> PyResult<()>,
321321
) -> PyResult<*mut ffi::PyObject> {
322+
#[cfg(all(PyPy, not(Py_3_8)))]
323+
{
324+
const PYPY_GOOD_VERSION: [u8; 3] = [7, 3, 8];
325+
let version = py
326+
.import("sys")?
327+
.getattr("implementation")?
328+
.getattr("version")?;
329+
if version.compare(crate::types::PyTuple::new(py, &PYPY_GOOD_VERSION))?
330+
== std::cmp::Ordering::Less
331+
{
332+
let warn = py.import("warnings")?.getattr("warn")?;
333+
warn.call1((
334+
"PyPy 3.7 versions older than 7.3.8 are known to have binary \
335+
compatibility issues which may cause segfaults. Please upgrade.",
336+
))?;
337+
}
338+
}
339+
322340
let module =
323341
unsafe { py.from_owned_ptr_or_err::<PyModule>(ffi::PyModule_Create(self.0.get()))? };
324342
initializer(py, module)?;

0 commit comments

Comments
 (0)