Skip to content

Commit

Permalink
remove gil-refs feature from full feature (#3930)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt authored Mar 4, 2024
1 parent 811a3e5 commit b08ee4b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ nightly = []
# This is mostly intended for testing purposes - activating *all* of these isn't particularly useful.
full = [
"macros",
"gil-refs",
# "multiple-pymethods", # TODO re-add this when MSRV is greater than 1.62
"anyhow",
"chrono",
Expand Down Expand Up @@ -140,7 +139,7 @@ members = [

[package.metadata.docs.rs]
no-default-features = true
features = ["full"]
features = ["full", "gil-refs"]
rustdoc-args = ["--cfg", "docsrs"]

[workspace.lints.clippy]
Expand Down
18 changes: 13 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_rust(session: nox.Session):
_run_cargo_test(session, features="abi3")
if "skip-full" not in session.posargs:
_run_cargo_test(session, features="full")
_run_cargo_test(session, features="full gil-refs")
_run_cargo_test(session, features="abi3 full")


Expand Down Expand Up @@ -617,6 +618,7 @@ def check_feature_powerset(session: nox.Session):

EXCLUDED_FROM_FULL = {
"nightly",
"gil-refs",
"extension-module",
"full",
"default",
Expand Down Expand Up @@ -658,10 +660,15 @@ def check_feature_powerset(session: nox.Session):
session.error("no experimental features exist; please simplify the noxfile")

features_to_skip = [
*EXCLUDED_FROM_FULL,
*(EXCLUDED_FROM_FULL - {"gil-refs"}),
*abi3_version_features,
]

# deny warnings
env = os.environ.copy()
rust_flags = env.get("RUSTFLAGS", "")
env["RUSTFLAGS"] = f"{rust_flags} -Dwarnings"

comma_join = ",".join
_run_cargo(
session,
Expand All @@ -672,6 +679,7 @@ def check_feature_powerset(session: nox.Session):
*(f"--group-features={comma_join(group)}" for group in features_to_group),
"check",
"--all-targets",
env=env,
)


Expand Down Expand Up @@ -715,8 +723,8 @@ def _get_feature_sets() -> Tuple[Tuple[str, ...], ...]:
"--no-default-features",
"--features=abi3",
),
("--features=full multiple-pymethods",),
("--features=abi3 full multiple-pymethods",),
("--features=full gil-refs multiple-pymethods",),
("--features=abi3 full gil-refs multiple-pymethods",),
)
else:
return (
Expand All @@ -725,8 +733,8 @@ def _get_feature_sets() -> Tuple[Tuple[str, ...], ...]:
"--no-default-features",
"--features=abi3",
),
("--features=full",),
("--features=abi3 full",),
("--features=full gil-refs",),
("--features=abi3 full gil-refs",),
)


Expand Down
4 changes: 2 additions & 2 deletions src/conversions/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,13 +980,13 @@ mod tests {
let td = new_py_datetime_ob(py, "timedelta", (0, 3600, 0));
let py_timedelta = new_py_datetime_ob(py, "timezone", (td,));
// Should be equal
assert!(offset.as_ref(py).eq(py_timedelta).unwrap());
assert!(offset.bind(py).eq(py_timedelta).unwrap());

// Same but with negative values
let offset = FixedOffset::east_opt(-3600).unwrap().to_object(py);
let td = new_py_datetime_ob(py, "timedelta", (0, -3600, 0));
let py_timedelta = new_py_datetime_ob(py, "timezone", (td,));
assert!(offset.as_ref(py).eq(py_timedelta).unwrap());
assert!(offset.bind(py).eq(py_timedelta).unwrap());
})
}

Expand Down
8 changes: 4 additions & 4 deletions src/conversions/num_bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ mod tests {
let mut f0 = 1.to_object(py);
let mut f1 = 1.to_object(py);
std::iter::from_fn(move || {
let f2 = f0.call_method1(py, "__add__", (f1.as_ref(py),)).unwrap();
let f2 = f0.call_method1(py, "__add__", (f1.bind(py),)).unwrap();
Some(std::mem::replace(&mut f0, std::mem::replace(&mut f1, f2)))
})
}
Expand All @@ -295,7 +295,7 @@ mod tests {
// Python -> Rust
assert_eq!(py_result.extract::<BigUint>(py).unwrap(), rs_result);
// Rust -> Python
assert!(py_result.as_ref(py).eq(rs_result).unwrap());
assert!(py_result.bind(py).eq(rs_result).unwrap());
}
});
}
Expand All @@ -308,7 +308,7 @@ mod tests {
// Python -> Rust
assert_eq!(py_result.extract::<BigInt>(py).unwrap(), rs_result);
// Rust -> Python
assert!(py_result.as_ref(py).eq(&rs_result).unwrap());
assert!(py_result.bind(py).eq(&rs_result).unwrap());

// negate

Expand All @@ -318,7 +318,7 @@ mod tests {
// Python -> Rust
assert_eq!(py_result.extract::<BigInt>(py).unwrap(), rs_result);
// Rust -> Python
assert!(py_result.as_ref(py).eq(rs_result).unwrap());
assert!(py_result.bind(py).eq(rs_result).unwrap());
}
});
}
Expand Down
14 changes: 3 additions & 11 deletions src/conversions/rust_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ use crate::sync::GILOnceCell;
use crate::types::any::PyAnyMethods;
use crate::types::string::PyStringMethods;
use crate::types::PyType;
use crate::{
intern, Bound, FromPyObject, IntoPy, Py, PyAny, PyObject, PyResult, Python, ToPyObject,
};
use crate::{Bound, FromPyObject, IntoPy, Py, PyAny, PyObject, PyResult, Python, ToPyObject};
use rust_decimal::Decimal;
use std::str::FromStr;

Expand All @@ -74,14 +72,8 @@ impl FromPyObject<'_> for Decimal {

static DECIMAL_CLS: GILOnceCell<Py<PyType>> = GILOnceCell::new();

fn get_decimal_cls(py: Python<'_>) -> PyResult<&PyType> {
DECIMAL_CLS
.get_or_try_init(py, || {
py.import_bound(intern!(py, "decimal"))?
.getattr(intern!(py, "Decimal"))?
.extract()
})
.map(|ty| ty.as_ref(py))
fn get_decimal_cls(py: Python<'_>) -> PyResult<&Bound<'_, PyType>> {
DECIMAL_CLS.get_or_try_init_type_ref(py, "decimal", "Decimal")
}

impl ToPyObject for Decimal {
Expand Down

0 comments on commit b08ee4b

Please sign in to comment.