Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 55f6514

Browse files
committedSep 13, 2024·
wip test PyO3 HEAD
1 parent ba8eab4 commit 55f6514

File tree

6 files changed

+29
-30
lines changed

6 files changed

+29
-30
lines changed
 

‎Cargo.lock

+11-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ rust-version = "1.75"
2929
[dependencies]
3030
# TODO it would be very nice to remove the "py-clone" feature as it can panic,
3131
# but needs a bit of work to make sure it's not used in the codebase
32-
pyo3 = { version = "0.22.2", features = ["generate-import-lib", "num-bigint", "py-clone"] }
32+
pyo3 = { git = "https://github.com/pyo3/pyo3", features = ["generate-import-lib", "num-bigint", "py-clone"] }
3333
regex = "1.10.6"
3434
strum = { version = "0.26.3", features = ["derive"] }
3535
strum_macros = "0.26.4"
@@ -46,7 +46,7 @@ base64 = "0.22.1"
4646
num-bigint = "0.4.6"
4747
python3-dll-a = "0.2.10"
4848
uuid = "1.10.0"
49-
jiter = { version = "0.5", features = ["python"] }
49+
jiter = { git = "https://github.com/pydantic/jiter", branch = "dh/pyo3-0.23", features = ["python"] }
5050
hex = "0.4.3"
5151

5252
[lib]
@@ -74,12 +74,12 @@ debug = true
7474
strip = false
7575

7676
[dev-dependencies]
77-
pyo3 = { version = "0.22.2", features = ["auto-initialize"] }
77+
pyo3 = { git = "https://github.com/pyo3/pyo3", features = ["auto-initialize"] }
7878

7979
[build-dependencies]
8080
version_check = "0.9.5"
8181
# used where logic has to be version/distribution specific, e.g. pypy
82-
pyo3-build-config = { version = "0.22.0" }
82+
pyo3-build-config = { git = "https://github.com/pyo3/pyo3" }
8383

8484
[lints.clippy]
8585
dbg_macro = "warn"

‎src/input/datetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl TzInfo {
527527
}
528528

529529
#[allow(unused_variables)]
530-
fn dst(&self, dt: &Bound<'_, PyAny>) -> Option<&PyDelta> {
530+
fn dst(&self, dt: &Bound<'_, PyAny>) -> Option<Bound<'_, PyDelta>> {
531531
None
532532
}
533533

‎src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn from_json<'py>(
6161
cache_mode: cache_strings,
6262
partial_mode: allow_partial,
6363
catch_duplicate_keys: false,
64-
lossless_floats: false,
64+
float_mode: jiter::FloatMode::Float,
6565
};
6666
parse_builder
6767
.python_parse(py, json_bytes)

‎src/lookup_key.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use core::slice::Iter;
2+
use std::convert::Infallible;
23
use std::fmt;
34

45
use pyo3::exceptions::{PyAttributeError, PyTypeError};
@@ -407,14 +408,17 @@ impl fmt::Display for PathItem {
407408
}
408409
}
409410

410-
impl ToPyObject for PathItem {
411-
fn to_object(&self, py: Python<'_>) -> PyObject {
411+
impl<'py> IntoPyObject<'py> for &'_ PathItem {
412+
type Target = PyAny;
413+
type Output = Bound<'py, PyAny>;
414+
type Error = Infallible;
415+
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
412416
match self {
413-
Self::S(_, val) => val.to_object(py),
414-
Self::Pos(val) => val.to_object(py),
415-
Self::Neg(val) => {
417+
PathItem::S(_, val) => Ok(val.bind(py).clone().into_any()),
418+
PathItem::Pos(val) => val.into_pyobject(py).map(Bound::into_any),
419+
PathItem::Neg(val) => {
416420
let neg_value = -(*val as i64);
417-
neg_value.to_object(py)
421+
neg_value.into_pyobject(py).map(Bound::into_any)
418422
}
419423
}
420424
}

‎src/validators/json.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use jiter::FloatMode;
12
use pyo3::intern;
23
use pyo3::prelude::*;
34
use pyo3::types::PyDict;
@@ -71,7 +72,7 @@ impl Validator for JsonValidator {
7172
cache_mode: state.cache_str(),
7273
partial_mode: PartialMode::Off,
7374
catch_duplicate_keys: false,
74-
lossless_floats: false,
75+
float_mode: FloatMode::Float,
7576
};
7677
let obj = parse_builder
7778
.python_parse(py, json_bytes)

0 commit comments

Comments
 (0)
Please sign in to comment.