Skip to content

Commit dbb6827

Browse files
chore(deps): Bump pyo3 from 0.25.1 to 0.29.0 in the cargo group across 1 directory (#49)
* chore(deps): Bump pyo3 in the cargo group across 1 directory Bumps the cargo group with 1 update in the / directory: [pyo3](https://github.com/pyo3/pyo3). Updates `pyo3` from 0.25.1 to 0.29.0 - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](PyO3/pyo3@v0.25.1...v0.29.0) --- updated-dependencies: - dependency-name: pyo3 dependency-version: 0.29.0 dependency-type: direct:production dependency-group: cargo ... Signed-off-by: dependabot[bot] <support@github.com> * fix: replace deprecated py.allow_threads() with py.detach() for pyo3 0.29 * fix: update TypeError message assertions for pyo3 0.29 str type errors pyo3 0.29 changed the TypeError message when passing an int where str is expected: - Old: "object cannot be interpreted as str" - New: "'int' object is not an instance of 'str'" Update the two failing test assertions to match the new message format. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 70a0e39 commit dbb6827

4 files changed

Lines changed: 19 additions & 49 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ default = ["python"]
1414
python = ["pyo3"]
1515

1616
[dependencies]
17-
pyo3 = { version = "0.25", features = ["extension-module"], optional = true }
17+
pyo3 = { version = "0.29", features = ["extension-module"], optional = true }
1818
rayon = "1.10"
1919

2020
[dev-dependencies]

src/python.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn hamming_distance_string(py: Python<'_>, a: &str, b: &str) -> PyResult<u64> {
7575
// release the GIL so other Python threads can run during the computation.
7676
let a_owned = a_bytes.to_vec();
7777
let b_owned = b_bytes.to_vec();
78-
py.allow_threads(move || hamming_distance_string_dispatch(&a_owned, &b_owned))
78+
py.detach(move || hamming_distance_string_dispatch(&a_owned, &b_owned))
7979
.map_err(PyValueError::new_err)
8080
}
8181

@@ -114,7 +114,7 @@ fn hamming_distance_bytes(
114114
let result = if a_slice.len() < GIL_RELEASE_THRESHOLD {
115115
hamming_distance_bytes_dispatch(a_slice, b_slice, -1)
116116
} else {
117-
py.allow_threads(move || hamming_distance_bytes_dispatch(a_slice, b_slice, -1))
117+
py.detach(move || hamming_distance_bytes_dispatch(a_slice, b_slice, -1))
118118
};
119119
drop(buf_a);
120120
drop(buf_b);
@@ -242,8 +242,7 @@ fn check_bytes_within_dist(
242242
return Err(PyValueError::new_err("array sizes need to be the same"));
243243
}
244244

245-
let result =
246-
py.allow_threads(move || hamming_distance_bytes_dispatch(a_slice, b_slice, max_dist));
245+
let result = py.detach(move || hamming_distance_bytes_dispatch(a_slice, b_slice, max_dist));
247246
drop(buf_a);
248247
drop(buf_b);
249248
Ok(result != u64::MAX)
@@ -296,7 +295,7 @@ fn check_bytes_arrays_first_within_dist(
296295
));
297296
}
298297

299-
let result = py.allow_threads(move || {
298+
let result = py.detach(move || {
300299
// Delegate to the serial early-exit implementation. `first` is never
301300
// parallelized: a parallel scan must evaluate every element to find the
302301
// minimum matching index, which is far slower for early/common matches.
@@ -343,7 +342,7 @@ fn check_bytes_arrays_best_within_dist(
343342
));
344343
}
345344

346-
let result = py.allow_threads(move || {
345+
let result = py.detach(move || {
347346
// Delegate to the rayon-parallel implementation (serial below
348347
// PAR_THRESHOLD_BYTES). Tie-break (lowest distance, then lowest index)
349348
// matches the previous serial behavior.
@@ -389,7 +388,7 @@ fn check_bytes_arrays_all_within_dist(
389388
));
390389
}
391390

392-
let results = py.allow_threads(move || {
391+
let results = py.detach(move || {
393392
// Delegate to the rayon-parallel implementation (serial below
394393
// PAR_THRESHOLD_BYTES). Results are returned in ascending index order.
395394
crate::bytes_array_all_within_dist(big_slice, small_slice, max_dist)

test/test_hexhamming.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_hamming_distance_byte(hex1, hex2, expected):
9090
@pytest.mark.parametrize(
9191
"hex1,hex2,exception,msg",
9292
(
93-
("abc", 3, TypeError, "object cannot be"),
93+
("abc", 3, TypeError, "not an instance of 'str'"),
9494
("abc", "a", ValueError, "strings are NOT the same length"),
9595
("lol", "foo", ValueError, "hex string contains invalid char"),
9696
("000abcdef", "011abcdgf", ValueError, "hex string contains invalid char"),
@@ -171,7 +171,7 @@ def test_check_bytes_within_dist(bytes1, bytes2, max_dist, expected):
171171
("000abcdef", "011abcdef", -1, ValueError, "`max_dist` must be >0"),
172172
("000abcdef", "011abcdzz", 3, ValueError, "hex string contains invalid char"),
173173
("000abcdef", "011abcdgf", 3, ValueError, "hex string contains invalid char"),
174-
("1f0abcdef", 3, 3, TypeError, "object cannot be"),
174+
("1f0abcdef", 3, 3, TypeError, "not an instance of 'str'"),
175175
("011abcdef", "00", 3, ValueError, "strings are NOT the same length"),
176176
),
177177
)

0 commit comments

Comments
 (0)