Skip to content

Commit

Permalink
Refer to GILOnceCell via the proper module (#9939)
Browse files Browse the repository at this point in the history
It's been in sync since 0.19
  • Loading branch information
alex authored Nov 29, 2023
1 parent f02c69f commit 11e9217
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/rust/src/backend/cipher_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ impl<'p> RegisteryBuilder<'p> {
fn get_cipher_registry(
py: pyo3::Python<'_>,
) -> CryptographyResult<&HashMap<RegistryKey, openssl::symm::Cipher>> {
static REGISTRY: pyo3::once_cell::GILOnceCell<HashMap<RegistryKey, openssl::symm::Cipher>> =
pyo3::once_cell::GILOnceCell::new();
static REGISTRY: pyo3::sync::GILOnceCell<HashMap<RegistryKey, openssl::symm::Cipher>> =
pyo3::sync::GILOnceCell::new();

REGISTRY.get_or_try_init(py, || {
let mut m = RegisteryBuilder::new(py);
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
pub struct LazyPyImport {
module: &'static str,
names: &'static [&'static str],
value: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
value: pyo3::sync::GILOnceCell<pyo3::PyObject>,
}

impl LazyPyImport {
pub const fn new(module: &'static str, names: &'static [&'static str]) -> LazyPyImport {
LazyPyImport {
module,
names,
value: pyo3::once_cell::GILOnceCell::new(),
value: pyo3::sync::GILOnceCell::new(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/x509/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ self_cell::self_cell!(
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.x509")]
pub(crate) struct Certificate {
pub(crate) raw: OwnedCertificate,
pub(crate) cached_extensions: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
pub(crate) cached_extensions: pyo3::sync::GILOnceCell<pyo3::PyObject>,
}

#[pyo3::prelude::pymethods]
Expand Down Expand Up @@ -388,7 +388,7 @@ fn load_der_x509_certificate(

Ok(Certificate {
raw,
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/x509/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ pub(crate) fn parse_and_cache_extensions<
F: Fn(&Extension<'_>) -> Result<Option<&'p pyo3::PyAny>, CryptographyError>,
>(
py: pyo3::Python<'p>,
cached_extensions: &pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
cached_extensions: &pyo3::sync::GILOnceCell<pyo3::PyObject>,
raw_extensions: &Option<RawExtensions<'_>>,
parse_ext: F,
) -> pyo3::PyResult<pyo3::PyObject> {
Expand Down
16 changes: 8 additions & 8 deletions src/rust/src/x509/crl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fn load_der_x509_crl(

Ok(CertificateRevocationList {
owned: Arc::new(owned),
revoked_certs: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
revoked_certs: pyo3::sync::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
})
}

Expand Down Expand Up @@ -75,8 +75,8 @@ self_cell::self_cell!(
struct CertificateRevocationList {
owned: Arc<OwnedCertificateRevocationList>,

revoked_certs: pyo3::once_cell::GILOnceCell<Vec<OwnedRevokedCertificate>>,
cached_extensions: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
revoked_certs: pyo3::sync::GILOnceCell<Vec<OwnedRevokedCertificate>>,
cached_extensions: pyo3::sync::GILOnceCell<pyo3::PyObject>,
}

impl CertificateRevocationList {
Expand All @@ -87,7 +87,7 @@ impl CertificateRevocationList {
fn revoked_cert(&self, py: pyo3::Python<'_>, idx: usize) -> RevokedCertificate {
RevokedCertificate {
owned: self.revoked_certs.get(py).unwrap()[idx].clone(),
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
}
}

Expand Down Expand Up @@ -375,7 +375,7 @@ impl CertificateRevocationList {
match owned {
Ok(o) => Ok(Some(RevokedCertificate {
owned: o,
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
})),
Err(()) => Ok(None),
}
Expand Down Expand Up @@ -464,7 +464,7 @@ impl CRLIterator {
.ok()?;
Some(RevokedCertificate {
owned: revoked,
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
})
}
}
Expand Down Expand Up @@ -492,7 +492,7 @@ impl Clone for OwnedRevokedCertificate {
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.x509")]
struct RevokedCertificate {
owned: OwnedRevokedCertificate,
cached_extensions: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
cached_extensions: pyo3::sync::GILOnceCell<pyo3::PyObject>,
}

#[pyo3::prelude::pymethods]
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/x509/csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ self_cell::self_cell!(
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.x509")]
struct CertificateSigningRequest {
raw: OwnedCsr,
cached_extensions: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
cached_extensions: pyo3::sync::GILOnceCell<pyo3::PyObject>,
}

#[pyo3::prelude::pymethods]
Expand Down Expand Up @@ -256,7 +256,7 @@ fn load_der_x509_csr(

Ok(CertificateSigningRequest {
raw,
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/x509/ocsp_req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ fn load_der_ocsp_request(

Ok(OCSPRequest {
raw,
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
})
}

#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.ocsp")]
struct OCSPRequest {
raw: OwnedOCSPRequest,

cached_extensions: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
cached_extensions: pyo3::sync::GILOnceCell<pyo3::PyObject>,
}

impl OCSPRequest {
Expand Down
10 changes: 5 additions & 5 deletions src/rust/src/x509/ocsp_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn load_der_ocsp_response(
};
Ok(OCSPResponse {
raw: Arc::new(raw),
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_single_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
cached_single_extensions: pyo3::sync::GILOnceCell::new(),
})
}

Expand All @@ -74,8 +74,8 @@ self_cell::self_cell!(
struct OCSPResponse {
raw: Arc<OwnedOCSPResponse>,

cached_extensions: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
cached_single_extensions: pyo3::once_cell::GILOnceCell<pyo3::PyObject>,
cached_extensions: pyo3::sync::GILOnceCell<pyo3::PyObject>,
cached_single_extensions: pyo3::sync::GILOnceCell<pyo3::PyObject>,
}

impl OCSPResponse {
Expand Down Expand Up @@ -243,7 +243,7 @@ impl OCSPResponse {
py,
x509::certificate::Certificate {
raw: raw_cert,
cached_extensions: pyo3::once_cell::GILOnceCell::new(),
cached_extensions: pyo3::sync::GILOnceCell::new(),
},
)?)?;
}
Expand Down

0 comments on commit 11e9217

Please sign in to comment.