diff --git a/src/rust/src/exceptions.rs b/src/rust/src/exceptions.rs index 67f57b9adcb5..95600faf08bd 100644 --- a/src/rust/src/exceptions.rs +++ b/src/rust/src/exceptions.rs @@ -2,6 +2,8 @@ // 2.0, and the BSD License. See the LICENSE file in the root of this repository // for complete details. +use pyo3::prelude::PyModuleMethods; + #[pyo3::prelude::pyclass( frozen, module = "cryptography.hazmat.bindings._rust.exceptions", @@ -23,20 +25,22 @@ pub(crate) enum Reasons { UNSUPPORTED_MAC, } -pyo3::import_exception!(cryptography.exceptions, AlreadyUpdated); -pyo3::import_exception!(cryptography.exceptions, AlreadyFinalized); -pyo3::import_exception!(cryptography.exceptions, InternalError); -pyo3::import_exception!(cryptography.exceptions, InvalidSignature); -pyo3::import_exception!(cryptography.exceptions, InvalidTag); -pyo3::import_exception!(cryptography.exceptions, NotYetFinalized); -pyo3::import_exception!(cryptography.exceptions, UnsupportedAlgorithm); -pyo3::import_exception!(cryptography.x509, AttributeNotFound); -pyo3::import_exception!(cryptography.x509, DuplicateExtension); -pyo3::import_exception!(cryptography.x509, UnsupportedGeneralNameType); -pyo3::import_exception!(cryptography.x509, InvalidVersion); +pyo3::import_exception_bound!(cryptography.exceptions, AlreadyUpdated); +pyo3::import_exception_bound!(cryptography.exceptions, AlreadyFinalized); +pyo3::import_exception_bound!(cryptography.exceptions, InternalError); +pyo3::import_exception_bound!(cryptography.exceptions, InvalidSignature); +pyo3::import_exception_bound!(cryptography.exceptions, InvalidTag); +pyo3::import_exception_bound!(cryptography.exceptions, NotYetFinalized); +pyo3::import_exception_bound!(cryptography.exceptions, UnsupportedAlgorithm); +pyo3::import_exception_bound!(cryptography.x509, AttributeNotFound); +pyo3::import_exception_bound!(cryptography.x509, DuplicateExtension); +pyo3::import_exception_bound!(cryptography.x509, UnsupportedGeneralNameType); +pyo3::import_exception_bound!(cryptography.x509, InvalidVersion); -pub(crate) fn create_submodule(py: pyo3::Python<'_>) -> pyo3::PyResult<&pyo3::prelude::PyModule> { - let submod = pyo3::prelude::PyModule::new(py, "exceptions")?; +pub(crate) fn create_submodule( + py: pyo3::Python<'_>, +) -> pyo3::PyResult> { + let submod = pyo3::prelude::PyModule::new_bound(py, "exceptions")?; submod.add_class::()?; diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 022c78eaf515..0e3b0a3150b7 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -99,7 +99,7 @@ fn _rust(py: pyo3::Python<'_>, m: &pyo3::types::PyModule) -> pyo3::PyResult<()> m.add_submodule(asn1::create_submodule(py)?)?; m.add_submodule(pkcs7::create_submodule(py)?)?; m.add_submodule(pkcs12::create_submodule(py)?.into_gil_ref())?; - m.add_submodule(exceptions::create_submodule(py)?)?; + m.add_submodule(exceptions::create_submodule(py)?.into_gil_ref())?; let x509_mod = pyo3::prelude::PyModule::new(py, "x509")?; crate::x509::certificate::add_to_module(x509_mod)?;