Skip to content

Commit 0769554

Browse files
authored
Update PyO3 to 0.27 (#138)
* Update PyO3 to 0.27 * Drop PyPy < 3.11 (PyO3 only supports 3.11+)
1 parent 2e794f4 commit 0769554

File tree

12 files changed

+270
-225
lines changed

12 files changed

+270
-225
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131
path: ~/Library/Caches/pip
3232
# more combinations:
3333
- os: ubuntu-22.04
34-
python-version: "pypy3.9"
34+
python-version: "pypy3.11"
3535
path: ~/.cache/pip
3636
- os: ubuntu-22.04-arm
37-
python-version: "pypy3.9"
37+
python-version: "pypy3.11"
3838
path: ~/.cache/pip
3939
steps:
4040
- uses: actions/checkout@v4

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@ crate-type = ["cdylib"]
1111
[dependencies]
1212
num-bigint = ">=0.4.3,<0.5"
1313
owned_chars = ">=0.3.2,<0.4"
14-
pyo3 = { version = ">=0.18,<0.19", features = ["num-bigint"] }
14+
# TODO: Migrate off py-clone as recommended in
15+
# https://pyo3.rs/v0.27.1/migration.html?highlight=bound#pyclone-is-now-gated-behind-the-py-clone-feature
16+
pyo3 = { version = ">=0.27,<0.28", features = ["num-bigint", "py-clone"] }
1517
thiserror = ">=1.0.37,<2"
1618
utf8-chars = ">=2.0.2,<3"
1719
compact_str = ">=0.7.1,<0.8"
1820
utf8-io = ">=0.16.0,<0.17"
1921
#utf8-read = ">=0.4.0,<0.5"
2022
utf8-read = { git = "https://github.com/smheidrich/utf8-read-rs.git", branch = "configurable-chunk-size" }
2123
utf8-width = ">=0.1.6,<0.2"
24+
# TODO: Rust nightly has this same feature; get rid of this dependency once it
25+
# becomes stable
26+
unwrap-infallible = "0.1.5"
2227

2328
[dev-dependencies]
2429
rstest = ">=0.18.1,<0.19"
2530

2631
[build-dependencies]
27-
pyo3-build-config = { version = "= 0.18.3", features = ["resolve-config"] }
32+
pyo3-build-config = { version = ">=0.27,<0.28", features = ["resolve-config"] }
2833

2934
# workaround for linkage errors when running cargo test:
3035
# https://pyo3.rs/v0.18.1/faq#i-cant-run-cargo-test-or-i-cant-build-in-a-cargo-workspace-im-having-linker-issues-like-symbol-not-found-or-undefined-reference-to-_pyexc_systemerror

src/int.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum AppropriateInt {
2323
Big(BigInt),
2424
}
2525

26-
#[cfg(all(any(Py_LIMITED_API, PyPy)))]
26+
#[cfg(any(Py_LIMITED_API, PyPy))]
2727
pub enum AppropriateInt {
2828
Normal(i64),
2929
Big(String), // to be converted into int on the Python side
@@ -50,16 +50,22 @@ impl FromStr for AppropriateInt {
5050
}
5151
}
5252

53-
impl IntoPy<PyObject> for AppropriateInt {
54-
fn into_py(self, py: Python<'_>) -> PyObject {
55-
match self {
56-
AppropriateInt::Normal(num) => num.into_py(py),
57-
AppropriateInt::Big(num) => num.into_py(py),
58-
}
53+
impl<'py> IntoPyObject<'py> for AppropriateInt {
54+
type Target = PyAny;
55+
type Output = Bound<'py, Self::Target>;
56+
type Error = PyErr;
57+
58+
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
59+
Ok(match self {
60+
AppropriateInt::Normal(num) => num.into_pyobject(py)?.into_any(),
61+
AppropriateInt::Big(num) => num.into_pyobject(py)?.into_any(),
62+
})
5963
}
6064
}
6165

6266
pub fn supports_bigint() -> bool {
67+
// TODO: I think both of these *do* support BigInt in recent PyO3 versions => test & lift
68+
// restriction
6369
#[cfg(any(Py_LIMITED_API, PyPy))]
6470
{
6571
return false;

0 commit comments

Comments
 (0)