From 5bbd21cc38e138ef1ee585b96d704cc1274d25ba Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 31 Oct 2022 15:42:12 +0800 Subject: [PATCH] Disable `PyModule::filename` on PyPy --- newsfragments/2715.fixed.md | 1 + pyo3-ffi/src/moduleobject.rs | 1 + src/types/module.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2715.fixed.md diff --git a/newsfragments/2715.fixed.md b/newsfragments/2715.fixed.md new file mode 100644 index 00000000000..00e856ee96a --- /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 27f4bb3cd59..f78730604ac 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 0b43a16812f..5006df7dc9c 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()