Merge pull request #1054 from davidhewitt/cleanup-pyerr-hidden-apis

Remove hidden PyErr::restore_and_minus1 and PyErr::restore_and_null
This commit is contained in:
Yuji Kanagawa 2020-07-20 12:29:27 +09:00 committed by GitHub
commit be67a152ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 18 deletions

View File

@ -25,10 +25,10 @@ pub fn py_init(fnname: &Ident, name: &Ident, doc: syn::LitStr) -> TokenStream {
use pyo3::derive_utils::ModuleDef;
const NAME: &'static str = concat!(stringify!(#name), "\0");
static MODULE_DEF: ModuleDef = unsafe { ModuleDef::new(NAME) };
match MODULE_DEF.make_module(#doc, #fnname) {
Ok(m) => m,
Err(e) => e.restore_and_null(unsafe { pyo3::Python::assume_gil_acquired() }),
}
let pool = pyo3::GILPool::new();
let py = pool.python();
pyo3::callback_body!(_py, { MODULE_DEF.make_module(#doc, #fnname) })
}
}
}

View File

@ -390,20 +390,6 @@ impl PyErr {
unsafe { ffi::PyErr_Restore(ptype.into_ptr(), pvalue, ptraceback.into_ptr()) }
}
/// Utility method for proc-macro code
#[doc(hidden)]
pub fn restore_and_null<T>(self, py: Python) -> *mut T {
self.restore(py);
std::ptr::null_mut()
}
/// Utility method for proc-macro code
#[doc(hidden)]
pub fn restore_and_minus1(self, py: Python) -> crate::libc::c_int {
self.restore(py);
-1
}
/// Issues a warning message.
/// May return a `PyErr` if warnings-as-errors is enabled.
pub fn warn(py: Python, category: &PyAny, message: &str, stacklevel: i32) -> PyResult<()> {