Skip to content

Commit 79de026

Browse files
authored
bump PyO3 to 0.28 (#233)
1 parent 2ad77c2 commit 79de026

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ resolver = "2"
44

55
[workspace.package]
66
authors = ["Samuel Colvin <samuel@pydantic.dev>"]
7-
version = "0.12.0"
7+
version = "0.13.0"
88
edition = "2021"
99
license = "MIT"
1010
keywords = ["JSON", "parsing", "deserialization", "iter"]
1111
categories = ["parser-implementations", "parsing"]
1212
homepage = "https://github.com/pydantic/jiter/"
1313
repository = "https://github.com/pydantic/jiter/"
1414
# MSRV should match pydantic-core
15-
rust-version = "1.75"
15+
rust-version = "1.83"
1616

1717
[profile.bench]
1818
debug = true
@@ -25,5 +25,5 @@ inherits = "release"
2525
debug = true
2626

2727
[workspace.dependencies]
28-
pyo3 = { version = "0.27" }
29-
pyo3-build-config = { version = "0.27" }
28+
pyo3 = { version = "0.28" }
29+
pyo3-build-config = { version = "0.28" }

crates/jiter/src/py_lossless_float.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use pyo3::exceptions::{PyTypeError, PyValueError};
22
use pyo3::prelude::*;
3+
use pyo3::py_format;
34
use pyo3::sync::PyOnceLock;
4-
use pyo3::types::PyType;
5+
use pyo3::types::{PyString, PyType};
56

67
use crate::Jiter;
78

@@ -33,7 +34,7 @@ impl<'py> FromPyObject<'_, 'py> for FloatMode {
3334

3435
/// Represents a float from JSON, by holding the underlying bytes representing a float from JSON.
3536
#[derive(Debug, Clone)]
36-
#[pyclass(module = "jiter")]
37+
#[pyclass(module = "jiter", skip_from_py_object)]
3738
pub struct LosslessFloat(Vec<u8>);
3839

3940
impl LosslessFloat {
@@ -78,8 +79,9 @@ impl LosslessFloat {
7879
std::str::from_utf8(&self.0).map_err(|_| PyValueError::new_err("Invalid UTF-8"))
7980
}
8081

81-
fn __repr__(&self) -> PyResult<String> {
82-
self.__str__().map(|s| format!("LosslessFloat({s})"))
82+
fn __repr__<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyString>> {
83+
let s = self.__str__()?;
84+
py_format!(py, "LosslessFloat({s})")
8385
}
8486
}
8587

crates/jiter/tests/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ fn utf8_range() {
393393
fn utf8_range_long() {
394394
for c in 0u8..255u8 {
395395
let mut json = vec![b'"', b':', c];
396-
json.extend(std::iter::repeat(b' ').take(20));
396+
json.extend(std::iter::repeat_n(b' ', 20));
397397
json.push(b'"');
398398
// dbg!(c, json.iter().map(|b| *b as char).collect::<Vec<_>>());
399399

@@ -632,9 +632,9 @@ fn invalid_escape_position() {
632632
fn simd_string_sizes() {
633633
for i in 0..100 {
634634
let mut json = vec![b'"'];
635-
json.extend(std::iter::repeat(b'a').take(i));
635+
json.extend(std::iter::repeat_n(b'a', i));
636636
json.push(b'"');
637-
json.extend(std::iter::repeat(b' ').take(40));
637+
json.extend(std::iter::repeat_n(b' ', 40));
638638

639639
let value = JsonValue::parse(&json, false).unwrap();
640640
let JsonValue::Str(s) = value else {

0 commit comments

Comments
 (0)