remove `gil-refs` feature from `full` feature (#3930)

This commit is contained in:
David Hewitt 2024-03-04 22:23:35 +00:00 committed by GitHub
parent 811a3e5d00
commit b08ee4b7e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 24 deletions

View File

@ -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",
@ -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]

View File

@ -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")
@ -617,6 +618,7 @@ def check_feature_powerset(session: nox.Session):
EXCLUDED_FROM_FULL = {
"nightly",
"gil-refs",
"extension-module",
"full",
"default",
@ -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,
@ -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,
)
@ -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 (
@ -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",),
)

View File

@ -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());
})
}

View File

@ -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)))
})
}
@ -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());
}
});
}
@ -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
@ -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());
}
});
}

View File

@ -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;
@ -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 {