Skip to content

Commit

Permalink
Rollback to pyo3 = { version = "0.16.6", features = ["abi3"] }
Browse files Browse the repository at this point in the history
In order to avoid `ImportError: PyO3 modules compiled for CPython 3.8 or
older may only be initialized once per interpreter process` introduced
since pyo3 >= 0.17.0, which only allow each #[pymodule] to be
initialized once, this PR temporarily rollback to pyo3 = 0.16.6.

It also remove the use of `PyUserWarning` which introduced since pyo3 >
0.18.0.

See PyO3/pyo3@78ba70d
See PyO3/pyo3@1d20f2a

Fixes pyca#694

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
  • Loading branch information
hswong3i committed Jan 3, 2024
1 parent accb0ba commit 1c04bb9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 46 deletions.
49 changes: 16 additions & 33 deletions src/_bcrypt/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/_bcrypt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
publish = false

[dependencies]
pyo3 = { version = "0.20.1", features = ["abi3"] }
pyo3 = { version = "0.16.6", features = ["abi3"] }
bcrypt = "0.15"
bcrypt-pbkdf = "0.10.0"
base64 = "0.21.5"
Expand Down
12 changes: 0 additions & 12 deletions src/_bcrypt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,6 @@ fn kdf<'p>(
));
}

if rounds < 50 && !ignore_few_rounds {
// They probably think bcrypt.kdf()'s rounds parameter is logarithmic,
// expecting this value to be slow enough (it probably would be if this
// were bcrypt). Emit a warning.
pyo3::PyErr::warn(
py,
pyo3::exceptions::PyUserWarning::type_object(py),
&format!("Warning: bcrypt.kdf() called with only {rounds} round(s). This few is not secure: the parameter is linear, like PBKDF2."),
3
)?;
}

pyo3::types::PyBytes::new_with(py, desired_key_bytes, |output| {
py.allow_threads(|| {
bcrypt_pbkdf::bcrypt_pbkdf(password, salt, rounds, output).unwrap();
Expand Down

0 comments on commit 1c04bb9

Please sign in to comment.