Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
name: Build Python distributions

on:
"on":
push:
pull_request:
schedule:
- cron: "0 6 * * *" # Daily 6AM UTC build
- cron: "0 6 * * *" # Daily 6AM UTC build

jobs:
build-wheels:
Expand Down
20 changes: 10 additions & 10 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ name = "fastbencode__bencode_rs"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = ">=0.25,<0.27", features = ["extension-module"] }
pyo3 = { version = "0.27", features = ["extension-module"] }
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ impl Decoder {

// Return as bytes or decode depending on bytestring_encoding
if let Some(encoding) = &self.bytestring_encoding {
Ok(PyString::from_object(&bytes_obj, encoding, "strict")?.into_any())
let encoding_cstr = std::ffi::CString::new(encoding.as_str())
.map_err(|_| PyValueError::new_err("invalid encoding string"))?;
Ok(
PyString::from_encoded_object(&bytes_obj, Some(&encoding_cstr), Some(c"strict"))?
.into_any(),
)
} else {
Ok(bytes_obj)
}
Expand Down Expand Up @@ -367,7 +372,7 @@ impl Encoder {
let mut keys: Vec<Bound<PyBytes>> = dict
.keys()
.iter()
.map(|key| key.extract::<Bound<PyBytes>>())
.map(|key| key.extract::<Bound<PyBytes>>().map_err(|e| e.into()))
.collect::<PyResult<Vec<_>>>()?;
keys.sort_by(|a, b| {
let a_str = a.extract::<&[u8]>().unwrap();
Expand Down
Loading