From d6baf21abcd3865e4a9cfefbe3375ad139e7efa0 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Mon, 9 Dec 2024 12:43:48 +0000 Subject: [PATCH] uprev PyO3 and add python 3.13 support (#86) --- .github/workflows/ci.yml | 6 +- .python-version | 2 +- Cargo.lock | 208 ++++++++------------------------------- Cargo.toml | 2 +- pyproject.toml | 2 + src/datetime.rs | 17 ++-- src/de.rs | 19 ++-- src/lib.rs | 7 +- src/ser.rs | 2 +- uv.lock | 25 +++++ 10 files changed, 98 insertions(+), 192 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c08f13..d1022df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] env: UV_PYTHON: ${{ matrix.python-version }} @@ -152,7 +152,7 @@ jobs: python-architecture: x86 - os: windows target: aarch64 - interpreter: 3.11 3.12 + interpreter: 3.11 3.12 3.13 runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-latest steps: @@ -184,7 +184,7 @@ jobs: with: target: ${{ matrix.target }} manylinux: ${{ matrix.manylinux || 'auto' }} - args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12' }} + args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12 3.13' }} rust-toolchain: stable docker-options: -e CI env: diff --git a/.python-version b/.python-version index 2c07333..24ee5b1 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11 +3.13 diff --git a/Cargo.lock b/Cargo.lock index f41ccd8..5b122e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ahash" @@ -17,15 +17,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "bitflags" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "cfg-if" @@ -52,9 +46,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indexmap" @@ -74,19 +68,9 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "lock_api" -version = "0.4.12" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "memoffset" @@ -105,59 +89,36 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.21.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +checksum = "e484fd2c8b4cb67ab05a318f1fd6fa8f199fcc30819f08f07d200809dba26c15" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -167,9 +128,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +checksum = "dc0e0469a84f208e20044b98965e1561028180219e35352a2afaf2b942beff3b" dependencies = [ "once_cell", "target-lexicon", @@ -177,9 +138,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +checksum = "eb1547a7f9966f6f1a0f0227564a9945fe36b90da5a93b3933fc3dc03fae372d" dependencies = [ "libc", "pyo3-build-config", @@ -187,9 +148,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +checksum = "fdb6da8ec6fa5cedd1626c886fc8749bdcbb09424a86461eb8cdf096b7c33257" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -199,9 +160,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +checksum = "38a385202ff5a92791168b1136afae5059d3ac118457bb7bc304c197c2d33e7d" dependencies = [ "heck", "proc-macro2", @@ -212,22 +173,13 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" -dependencies = [ - "bitflags", -] - [[package]] name = "rtoml" version = "0.11.0" @@ -239,43 +191,31 @@ dependencies = [ "toml", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "serde" -version = "1.0.203" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - [[package]] name = "syn" -version = "2.0.68" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -284,9 +224,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "toml" @@ -300,9 +240,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unindent" @@ -312,9 +252,9 @@ checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -322,84 +262,20 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" - [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index f4af497..b826c5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] toml = {version = "0.5.9", features = ["preserve_order"]} serde = "1.0.126" -pyo3 = "0.21.2" +pyo3 = "0.23.3" ahash = "0.8.1" nohash-hasher = "0.2.0" diff --git a/pyproject.toml b/pyproject.toml index fa9fc7e..917cdf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", @@ -44,6 +45,7 @@ Source = "https://github.com/samuelcolvin/rtoml" dev = [ "coverage[toml]>=7.6.9", "dirty-equals>=0.8.0", + "maturin>=1.7.8", "pytest>=8.3.4", "pytest-pretty>=1.2.0", "pytest-speed>=0.3.5", diff --git a/src/datetime.rs b/src/datetime.rs index 0524b6d..539011d 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -1,5 +1,6 @@ use pyo3::prelude::*; use pyo3::types::{PyDate, PyDateTime, PyDelta, PyTime, PyTzInfo}; +use pyo3::IntoPyObjectExt; use toml::value::{Datetime as TomlDatetime, Offset as TomlOffset}; @@ -17,7 +18,7 @@ pub fn parse(py: Python, datetime: &TomlDatetime) -> PyResult { None => None, }; - PyDateTime::new_bound( + let dt = PyDateTime::new( py, date.year as i32, date.month, @@ -27,13 +28,11 @@ pub fn parse(py: Python, datetime: &TomlDatetime) -> PyResult { t.second, t.nanosecond / 1000, tz_info.as_ref(), - ) - .map(|dt| dt.to_object(py)) - } - (Some(date), None) => PyDate::new_bound(py, date.year as i32, date.month, date.day).map(|d| d.to_object(py)), - (None, Some(t)) => { - PyTime::new_bound(py, t.hour, t.minute, t.second, t.nanosecond / 1000, None).map(|t| t.to_object(py)) + )?; + Ok(dt.into_py_any(py)?) } + (Some(date), None) => Ok(PyDate::new(py, date.year as i32, date.month, date.day)?.into_py_any(py)?), + (None, Some(t)) => Ok(PyTime::new(py, t.hour, t.minute, t.second, t.nanosecond / 1000, None)?.into_py_any(py)?), (None, None) => { // AFAIK this can't actually happen unreachable!("either time or date (or both) are required") @@ -59,14 +58,14 @@ impl TzInfo { } fn utcoffset<'py>(&self, dt: &Bound<'py, PyDateTime>) -> PyResult> { - PyDelta::new_bound(dt.py(), 0, self.seconds(), 0, true) + PyDelta::new(dt.py(), 0, self.seconds(), 0, true) } fn tzname(&self, _dt: &Bound<'_, PyAny>) -> String { self.__str__() } - fn dst(&self, _dt: &Bound<'_, PyAny>) -> Option<&PyDelta> { + fn dst<'py>(&self, _dt: &Bound<'py, PyAny>) -> Option> { None } diff --git a/src/de.rs b/src/de.rs index 7a87800..ce84167 100644 --- a/src/de.rs +++ b/src/de.rs @@ -6,6 +6,7 @@ use std::str::FromStr; use pyo3::prelude::*; use pyo3::types::PyDict; +use pyo3::IntoPyObjectExt; use ahash::RandomState; use nohash_hasher::NoHashHasher; @@ -51,28 +52,28 @@ impl<'de> Visitor<'de> for PyDeserializer<'_> { where E: de::Error, { - Ok(value.into_py(self.py)) + value.into_py_any(self.py).map_err(de::Error::custom) } fn visit_i64(self, value: i64) -> Result where E: de::Error, { - Ok(value.into_py(self.py)) + value.into_py_any(self.py).map_err(de::Error::custom) } fn visit_u64(self, value: u64) -> Result where E: de::Error, { - Ok(value.into_py(self.py)) + value.into_py_any(self.py).map_err(de::Error::custom) } fn visit_f64(self, value: f64) -> Result where E: de::Error, { - Ok(value.into_py(self.py)) + value.into_py_any(self.py).map_err(de::Error::custom) } fn visit_str(self, value: &str) -> Result @@ -81,7 +82,7 @@ impl<'de> Visitor<'de> for PyDeserializer<'_> { { match self.none_value { Some(none_value) if value == none_value => Ok(self.py.None()), - _ => Ok(value.into_py(self.py)), + _ => value.into_py_any(self.py).map_err(de::Error::custom), } } @@ -99,7 +100,7 @@ impl<'de> Visitor<'de> for PyDeserializer<'_> { elements.push(elem); } - Ok(elements.into_py(self.py)) + elements.into_py_any(self.py).map_err(de::Error::custom) } fn visit_map(self, mut map_access: A) -> Result @@ -119,7 +120,7 @@ impl<'de> Visitor<'de> for PyDeserializer<'_> { let mut key_set = NoHashSet::::with_hasher(BuildHasherDefault::default()); key_set.insert(hash_builder.hash_one(&first_key)); - let dict = PyDict::new_bound(self.py); + let dict = PyDict::new(self.py); dict.set_item(first_key, first_value).map_err(de::Error::custom)?; while let Some((key, value)) = @@ -132,9 +133,9 @@ impl<'de> Visitor<'de> for PyDeserializer<'_> { } } - Ok(dict.into_py(self.py)) + dict.into_py_any(self.py).map_err(de::Error::custom) } - None => Ok(PyDict::new_bound(self.py).into_py(self.py)), + None => PyDict::new(self.py).into_py_any(self.py).map_err(de::Error::custom), } } } diff --git a/src/lib.rs b/src/lib.rs index 8c50a3d..be1840b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ create_exception!(_rtoml, TomlParsingError, PyValueError); create_exception!(_rtoml, TomlSerializationError, PyValueError); #[pyfunction] +#[pyo3(signature = (toml_data, none_value=None))] fn deserialize(py: Python, toml_data: String, none_value: Option<&str>) -> PyResult { let mut deserializer = Deserializer::new(&toml_data); let seed = de::PyDeserializer::new(py, none_value); @@ -24,6 +25,7 @@ fn deserialize(py: Python, toml_data: String, none_value: Option<&str>) -> PyRes } #[pyfunction] +#[pyo3(signature = (obj, none_value=None))] fn serialize(py: Python, obj: Bound<'_, PyAny>, none_value: Option<&str>) -> PyResult { let s = SerializePyObject::new(py, obj, none_value); match to_toml_string(&s) { @@ -33,6 +35,7 @@ fn serialize(py: Python, obj: Bound<'_, PyAny>, none_value: Option<&str>) -> PyR } #[pyfunction] +#[pyo3(signature = (obj, none_value=None))] fn serialize_pretty(py: Python, obj: Bound<'_, PyAny>, none_value: Option<&str>) -> PyResult { let s = SerializePyObject::new(py, obj, none_value); match to_toml_string_pretty(&s) { @@ -53,8 +56,8 @@ pub fn get_version() -> String { #[pymodule] fn _rtoml(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add("TomlParsingError", py.get_type_bound::())?; - m.add("TomlSerializationError", py.get_type_bound::())?; + m.add("TomlParsingError", py.get_type::())?; + m.add("TomlSerializationError", py.get_type::())?; let version = get_version(); m.add("__version__", version.clone())?; // keep VERSION for compatibility diff --git a/src/ser.rs b/src/ser.rs index b5b0986..b423f1e 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -176,7 +176,7 @@ fn table_key<'py, E: SerError>(key: &'py Bound<'py, PyAny>, none_value: Option<& fn any_repr(obj: &Bound<'_, PyAny>) -> String { let typ = obj.get_type(); - let name = typ.name().unwrap_or_else(|_| "unknown".into()); + let name = typ.name().unwrap_or_else(|_| PyString::new(obj.py(), "unknown")); match obj.repr() { Ok(repr) => format!("{repr} ({name})"), Err(_) => name.to_string(), diff --git a/uv.lock b/uv.lock index eae391b..2cae898 100644 --- a/uv.lock +++ b/uv.lock @@ -135,6 +135,29 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528 }, ] +[[package]] +name = "maturin" +version = "1.7.8" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "tomli", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ab/1e/085ddc0e5b08ae7af7a743a0dd6ed06b22a1332288488f1a333137885150/maturin-1.7.8.tar.gz", hash = "sha256:649c6ef3f0fa4c5f596140d761dc5a4d577c485cc32fb5b9b344a8280352880d", size = 195704 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/ed/c8bb26e91c879e418ae1b01630722ed20b6fe0e6755be8d538d83666f136/maturin-1.7.8-py3-none-linux_armv6l.whl", hash = "sha256:c6950fd2790acd93265e1501cea66f9249cff19724654424ca75a3b17ebb315b", size = 7515691 }, + { url = "https://files.pythonhosted.org/packages/38/7a/573f969315f0b92a09a0a565d45e98812c87796e2e19a7856159ab234faf/maturin-1.7.8-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:f98288d5c382bacf0c076871dfd50c38f1eb2248f417551e98dd6f47f6ee8afa", size = 14434454 }, + { url = "https://files.pythonhosted.org/packages/a6/17/46834841fbf19231487f185e68b95ca348cc05cce49be8787e0bc7e9dc47/maturin-1.7.8-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b2d4e0f674ca29864e6b86c2eb9fee8236d1c7496c25f7300e34229272468f4c", size = 7509122 }, + { url = "https://files.pythonhosted.org/packages/c1/8f/bf8b4871eb390a4baef2e0bb5016852c7c0311a9772e2945534cfa2ee40e/maturin-1.7.8-py3-none-manylinux_2_12_i686.manylinux2010_i686.musllinux_1_1_i686.whl", hash = "sha256:6cafb17bf57822bdc04423d9e3e766d42918d474848fe9833e397267514ba891", size = 7598870 }, + { url = "https://files.pythonhosted.org/packages/dc/43/c842be67a7c59568082345249b956138ae93d0b2474fb41c186ce26d05e1/maturin-1.7.8-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl", hash = "sha256:2b2bdee0c3a84696b3a809054c43ead1a04b7b3321cbd5b8f5676e4ba4691d0f", size = 7932310 }, + { url = "https://files.pythonhosted.org/packages/12/12/42435d05f2d6c75eb621751e6f021d29eb34d18e3b9c5c94d828744c2d54/maturin-1.7.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:b8188b71259fc2bc568d9c8acc186fcfed96f42539bcb55b8e6f4ec26e411f37", size = 7321964 }, + { url = "https://files.pythonhosted.org/packages/b4/26/f3272ee985ebf9b3e8c4cd4f4efb022af1e12c9f53aed0dcc9a255399f4e/maturin-1.7.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.musllinux_1_1_armv7l.whl", hash = "sha256:a4f58c2a53c2958a1bf090960b08b28e676136cd88ac2f5dfdcf1b14ea54ec06", size = 7408613 }, + { url = "https://files.pythonhosted.org/packages/36/7d/be27bcc7d3ac6e6c2136a8ec0cc56f227a292d6cfdde55e095b6c0aa24a9/maturin-1.7.8-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.musllinux_1_1_ppc64le.whl", hash = "sha256:c5d6c0c631d1fc646cd3834795e6cfd72ab4271d289df7e0f911261a02bec75f", size = 9496974 }, + { url = "https://files.pythonhosted.org/packages/e1/e8/0d7323e9a31c11edf69c4473d73eca74803ce3e2390abf8ae3ac7eb10b04/maturin-1.7.8-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c23664d19dadcbf800ef70f26afb2e0485a985c62889930934f019c565534c23", size = 10828401 }, + { url = "https://files.pythonhosted.org/packages/7e/82/5080e052c0d8c9872f6d4b94cae84c17ed7f2ea270d709210ea6445b655f/maturin-1.7.8-py3-none-win32.whl", hash = "sha256:403eebf1afa6f19b49425f089e39c53b8e597bc86a47f3a76e828dc78d27fa80", size = 6845240 }, + { url = "https://files.pythonhosted.org/packages/6d/c9/9b162361ded893f36038c2f8ac6a972ec441c11df8d17c440997eb28090f/maturin-1.7.8-py3-none-win_amd64.whl", hash = "sha256:1ce48d007438b895f8665314b6748ac0dab31e4f32049a60b52281dd2dccbdde", size = 7762332 }, + { url = "https://files.pythonhosted.org/packages/fa/40/46d4742db742f69a7fe0054cd7c82bc79b2d70cb8c91f7e737e75c28a5f3/maturin-1.7.8-py3-none-win_arm64.whl", hash = "sha256:cc92a62953205e8945b6cfe6943d6a8576a4442d30d9c67141f944f4f4640e62", size = 6501353 }, +] + [[package]] name = "mdurl" version = "0.1.2" @@ -286,6 +309,7 @@ source = { editable = "." } dev = [ { name = "coverage", extra = ["toml"] }, { name = "dirty-equals" }, + { name = "maturin" }, { name = "pytest" }, { name = "pytest-pretty" }, { name = "pytest-speed" }, @@ -301,6 +325,7 @@ lint = [ dev = [ { name = "coverage", extras = ["toml"], specifier = ">=7.6.9" }, { name = "dirty-equals", specifier = ">=0.8.0" }, + { name = "maturin", specifier = ">=1.7.8" }, { name = "pytest", specifier = ">=8.3.4" }, { name = "pytest-pretty", specifier = ">=1.2.0" }, { name = "pytest-speed", specifier = ">=0.3.5" },