-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust path for GIL Refs deprecation warnings (#3968)
- Loading branch information
1 parent
cbed7c1
commit 02e188e
Showing
9 changed files
with
113 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,68 @@ | ||
//! Symbols used to denote deprecated usages of PyO3's proc macros. | ||
use crate::{PyResult, Python}; | ||
|
||
#[deprecated(since = "0.20.0", note = "use `#[new]` instead of `#[__new__]`")] | ||
pub const PYMETHODS_NEW_DEPRECATED_FORM: () = (); | ||
|
||
pub fn inspect_type<T>(t: T) -> (T, GilRefs<T>) { | ||
(t, GilRefs::new()) | ||
} | ||
|
||
pub fn inspect_fn<A, T>(f: fn(A) -> PyResult<T>, _: &GilRefs<A>) -> fn(A) -> PyResult<T> { | ||
f | ||
} | ||
|
||
pub struct GilRefs<T>(NotAGilRef<T>); | ||
pub struct NotAGilRef<T>(std::marker::PhantomData<T>); | ||
|
||
pub trait IsGilRef {} | ||
|
||
impl<T: crate::PyNativeType> IsGilRef for &'_ T {} | ||
|
||
impl<T> GilRefs<T> { | ||
#[allow(clippy::new_without_default)] | ||
pub fn new() -> Self { | ||
GilRefs(NotAGilRef(std::marker::PhantomData)) | ||
} | ||
} | ||
|
||
impl GilRefs<Python<'_>> { | ||
#[cfg_attr( | ||
not(feature = "gil-refs"), | ||
deprecated(since = "0.21.0", note = "use `wrap_pyfunction_bound!` instead") | ||
)] | ||
pub fn is_python(&self) {} | ||
} | ||
|
||
impl<T: IsGilRef> GilRefs<T> { | ||
#[cfg_attr( | ||
not(feature = "gil-refs"), | ||
deprecated( | ||
since = "0.21.0", | ||
note = "use `&Bound<'_, T>` instead for this function argument" | ||
) | ||
)] | ||
pub fn function_arg(&self) {} | ||
#[cfg_attr( | ||
not(feature = "gil-refs"), | ||
deprecated( | ||
since = "0.21.0", | ||
note = "use `&Bound<'_, PyAny>` as the argument for this `from_py_with` extractor" | ||
) | ||
)] | ||
pub fn from_py_with_arg(&self) {} | ||
} | ||
|
||
impl<T> NotAGilRef<T> { | ||
pub fn function_arg(&self) {} | ||
pub fn from_py_with_arg(&self) {} | ||
pub fn is_python(&self) {} | ||
} | ||
|
||
impl<T> std::ops::Deref for GilRefs<T> { | ||
type Target = NotAGilRef<T>; | ||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters