diff --git a/newsfragments/2715.fixed.md b/newsfragments/2715.fixed.md new file mode 100644 index 00000000..00e856ee --- /dev/null +++ b/newsfragments/2715.fixed.md @@ -0,0 +1 @@ +Disable `PyModule::filename` on PyPy diff --git a/pyo3-ffi/src/moduleobject.rs b/pyo3-ffi/src/moduleobject.rs index 27f4bb3c..f7873060 100644 --- a/pyo3-ffi/src/moduleobject.rs +++ b/pyo3-ffi/src/moduleobject.rs @@ -32,6 +32,7 @@ extern "C" { #[cfg(not(all(windows, PyPy)))] #[deprecated(note = "Python 3.2")] pub fn PyModule_GetFilename(arg1: *mut PyObject) -> *const c_char; + #[cfg(not(PyPy))] pub fn PyModule_GetFilenameObject(arg1: *mut PyObject) -> *mut PyObject; // skipped non-limited _PyModule_Clear // skipped non-limited _PyModule_ClearDict diff --git a/src/types/module.rs b/src/types/module.rs index 0b43a168..5006df7d 100644 --- a/src/types/module.rs +++ b/src/types/module.rs @@ -203,7 +203,7 @@ impl PyModule { /// Returns the filename (the `__file__` attribute) of the module. /// /// May fail if the module does not have a `__file__` attribute. - #[cfg(not(all(windows, PyPy)))] + #[cfg(not(PyPy))] pub fn filename(&self) -> PyResult<&str> { unsafe { self.py()