Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
path: ~/Library/Caches/pip
# more combinations:
- os: ubuntu-22.04
python-version: "pypy3.9"
python-version: "pypy3.11"
path: ~/.cache/pip
- os: ubuntu-22.04-arm
python-version: "pypy3.9"
python-version: "pypy3.11"
path: ~/.cache/pip
steps:
- uses: actions/checkout@v4
Expand Down
139 changes: 49 additions & 90 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

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

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

# workaround for linkage errors when running cargo test:
# 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
Expand Down
20 changes: 13 additions & 7 deletions src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum AppropriateInt {
Big(BigInt),
}

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

impl IntoPy<PyObject> for AppropriateInt {
fn into_py(self, py: Python<'_>) -> PyObject {
match self {
AppropriateInt::Normal(num) => num.into_py(py),
AppropriateInt::Big(num) => num.into_py(py),
}
impl<'py> IntoPyObject<'py> for AppropriateInt {
type Target = PyAny;
type Output = Bound<'py, Self::Target>;
type Error = PyErr;

fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
Ok(match self {
AppropriateInt::Normal(num) => num.into_pyobject(py)?.into_any(),
AppropriateInt::Big(num) => num.into_pyobject(py)?.into_any(),
})
}
}

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