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
5 changes: 0 additions & 5 deletions pyo3-build-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,6 @@ pub fn print_feature_cfgs() {
/// - <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg>
#[doc(hidden)]
pub fn print_expected_cfgs() {
if rustc_minor_version().is_some_and(|version| version < 80) {
// rustc 1.80.0 stabilized `rustc-check-cfg` feature, don't emit before
return;
}

println!("cargo:rustc-check-cfg=cfg(Py_LIMITED_API)");
println!("cargo:rustc-check-cfg=cfg(Py_GIL_DISABLED)");
println!("cargo:rustc-check-cfg=cfg(PyPy)");
Expand Down
15 changes: 2 additions & 13 deletions src/coroutine/cancel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{Py, PyAny};
use std::future::Future;
use std::pin::Pin;
use std::future::poll_fn;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll, Waker};

Expand Down Expand Up @@ -44,7 +43,7 @@ impl CancelHandle {

/// Retrieve the exception thrown in the associated coroutine.
pub async fn cancelled(&mut self) -> Py<PyAny> {
Cancelled(self).await
poll_fn(|cx| self.poll_cancelled(cx)).await
}

#[doc(hidden)]
Expand All @@ -53,16 +52,6 @@ impl CancelHandle {
}
}

// Because `poll_fn` is not available in MSRV
struct Cancelled<'a>(&'a mut CancelHandle);

impl Future for Cancelled<'_> {
type Output = Py<PyAny>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.0.poll_cancelled(cx)
}
}

#[doc(hidden)]
pub struct ThrowCallback(Arc<Mutex<Inner>>);

Expand Down
2 changes: 1 addition & 1 deletion src/impl_/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl IntoPyCallbackOutput<'_, ffi::Py_ssize_t> for usize {
}
}

// Converters needed for `#[pyproto]` implementations
// Conversion traits needed by pyo3's macros

impl IntoPyCallbackOutput<'_, bool> for bool {
#[inline]
Expand Down
18 changes: 6 additions & 12 deletions src/impl_/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,21 +1060,15 @@ impl<T> PyClassThreadChecker<T> for ThreadCheckerImpl {
}

/// Trait denoting that this class is suitable to be used as a base type for PyClass.
#[cfg_attr(
Py_LIMITED_API,
diagnostic::on_unimplemented(
message = "pyclass `{Self}` cannot be subclassed",
label = "required for `#[pyclass(extends={Self})]`",
note = "`{Self}` must have `#[pyclass(subclass)]` to be eligible for subclassing",
note = "with the `abi3` feature enabled, PyO3 does not support subclassing native types",
)
#[diagnostic::on_unimplemented(
message = "pyclass `{Self}` cannot be subclassed",
label = "required for `#[pyclass(extends={Self})]`",
note = "`{Self}` must have `#[pyclass(subclass)]` to be eligible for subclassing"
)]
#[cfg_attr(
not(Py_LIMITED_API),
all(Py_LIMITED_API, not(Py_3_12)),
diagnostic::on_unimplemented(
message = "pyclass `{Self}` cannot be subclassed",
label = "required for `#[pyclass(extends={Self})]`",
note = "`{Self}` must have `#[pyclass(subclass)]` to be eligible for subclassing",
note = "subclassing native types requires Python >= 3.12 when using the `abi3` feature",
)
)]
pub trait PyClassBaseType: Sized {
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
//! ```rust
//! use pyo3::prelude::*;
//! use pyo3::types::IntoPyDict;
//! use pyo3::ffi::c_str;
//!
//! fn main() -> PyResult<()> {
//! Python::attach(|py| {
Expand Down
3 changes: 0 additions & 3 deletions src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ impl Python<'_> {
///
/// ```
/// use pyo3::prelude::*;
/// use pyo3::ffi::c_str;
///
/// # fn main() -> PyResult<()> {
/// Python::attach(|py| -> PyResult<()> {
Expand Down Expand Up @@ -581,7 +580,6 @@ impl<'py> Python<'py> {
///
/// ```
/// # use pyo3::prelude::*;
/// # use pyo3::ffi::c_str;
/// # Python::attach(|py| {
/// let result = py.eval(c"[i * 10 for i in range(5)]", None, None).unwrap();
/// let res: Vec<i64> = result.extract().unwrap();
Expand Down Expand Up @@ -611,7 +609,6 @@ impl<'py> Python<'py> {
/// use pyo3::{
/// prelude::*,
/// types::{PyBytes, PyDict},
/// ffi::c_str,
/// };
/// Python::attach(|py| {
/// let locals = PyDict::new(py);
Expand Down
1 change: 0 additions & 1 deletion src/types/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::{ffi, Bound, Py, PyAny, PyErr, PyResult};
///
/// ```rust
/// use pyo3::prelude::*;
/// use pyo3::ffi::c_str;
///
/// # fn main() -> PyResult<()> {
/// Python::attach(|py| -> PyResult<()> {
Expand Down
1 change: 0 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub use self::weakref::{PyWeakref, PyWeakrefMethods, PyWeakrefProxy, PyWeakrefRe
/// ```rust
/// use pyo3::prelude::*;
/// use pyo3::types::PyDict;
/// use pyo3::ffi::c_str;
///
/// # pub fn main() -> PyResult<()> {
/// Python::attach(|py| {
Expand Down
1 change: 0 additions & 1 deletion src/types/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ impl PyModule {
///
/// ```rust
/// use pyo3::prelude::*;
/// use pyo3::ffi::c_str;
/// use std::ffi::CString;
///
/// # fn main() -> PyResult<()> {
Expand Down
1 change: 0 additions & 1 deletion src/types/weakref/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ impl PyWeakrefProxy {
)]
/// use pyo3::prelude::*;
/// use pyo3::types::PyWeakrefProxy;
/// use pyo3::ffi::c_str;
///
/// #[pyclass(weakref)]
/// struct Foo { /* fields omitted */ }
Expand Down
1 change: 0 additions & 1 deletion src/types/weakref/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ impl PyWeakrefReference {
)]
/// use pyo3::prelude::*;
/// use pyo3::types::PyWeakrefReference;
/// use pyo3::ffi::c_str;
///
/// #[pyclass(weakref)]
/// struct Foo { /* fields omitted */ }
Expand Down
2 changes: 1 addition & 1 deletion tests/test_compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn test_compile_errors() {
t.pass("tests/ui/pymodule_missing_docs.rs");
#[cfg(not(any(Py_LIMITED_API, feature = "experimental-inspect")))]
t.pass("tests/ui/forbid_unsafe.rs");
#[cfg(all(Py_LIMITED_API, not(Py_3_12), not(feature = "experimental-async")))]
#[cfg(all(Py_LIMITED_API, not(Py_3_12), feature = "experimental-async"))]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this used to be never true? I've inverted the predicate and now it seems to run again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably related to #5913

I am also beginning to play with #5863 which might allow us some room for improvements here.

// output changes with async feature
t.compile_fail("tests/ui/abi3_inheritance.rs");
#[cfg(all(Py_LIMITED_API, not(Py_3_9)))]
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/abi3_inheritance.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ error[E0277]: pyclass `PyException` cannot be subclassed
|
= help: the trait `PyClassBaseType` is not implemented for `PyException`
= note: `PyException` must have `#[pyclass(subclass)]` to be eligible for subclassing
= note: with the `abi3` feature enabled, PyO3 does not support subclassing native types
= note: subclassing native types requires Python >= 3.12 when using the `abi3` feature
help: the trait `PyClassBaseType` is implemented for `PyAny`
--> src/types/any.rs
|
Expand All @@ -22,7 +22,7 @@ error[E0277]: pyclass `PyException` cannot be subclassed
|
= help: the trait `PyClassBaseType` is not implemented for `PyException`
= note: `PyException` must have `#[pyclass(subclass)]` to be eligible for subclassing
= note: with the `abi3` feature enabled, PyO3 does not support subclassing native types
= note: subclassing native types requires Python >= 3.12 when using the `abi3` feature
help: the trait `PyClassBaseType` is implemented for `PyAny`
--> src/types/any.rs
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/abi3_nativetype_inheritance.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ error[E0277]: pyclass `PyDict` cannot be subclassed
|
= help: the trait `PyClassBaseType` is not implemented for `PyDict`
= note: `PyDict` must have `#[pyclass(subclass)]` to be eligible for subclassing
= note: with the `abi3` feature enabled, PyO3 does not support subclassing native types
= note: subclassing native types requires Python >= 3.12 when using the `abi3` feature
help: the trait `PyClassBaseType` is implemented for `PyAny`
--> src/types/any.rs
|
Expand All @@ -22,7 +22,7 @@ error[E0277]: pyclass `PyDict` cannot be subclassed
|
= help: the trait `PyClassBaseType` is not implemented for `PyDict`
= note: `PyDict` must have `#[pyclass(subclass)]` to be eligible for subclassing
= note: with the `abi3` feature enabled, PyO3 does not support subclassing native types
= note: subclassing native types requires Python >= 3.12 when using the `abi3` feature
help: the trait `PyClassBaseType` is implemented for `PyAny`
--> src/types/any.rs
|
Expand Down
Loading