Add weakref Python types (#3835)
* Add vscode folder to gitignore * Initial work on PyWeakRef (weakref.ReferenceType) * Add documentation for PyWeakRef::upgrade * Add missing docs for PyWeakRef * Add PyWeakProxy * Add PyWeakCallableProxy * Add PyWeakRefMethods::upgrade_exact and prevent unnecessary panicing * Change PyWeakRefMethods to exclude infeasible errors. As a result of the checks made about the objectpointers in PyO3, all errors in PyWeakref_GetObject are already caught. Therefor there is no need to check for these errors in the non-ffi layer. * Add towncrier changes * Update weakref type doctests to use `py.run_bound` * Fix to adhere to MSRV * Make weakref tests independent from macros feature * Change Weakref tests * Remove forgotten Debug marcos * Processed .gitignore and PyResultExt feedback * Change new methods of weakref types to remove dangling pointers * Change to reflect deprecation of PyErr::value for PyErr::value_bound * Change Tests so different class name in older python versions is accounted for * Change formatting * Make tests ABI3 compatible * Prevent the use of PyClass in test for weakref under abi3 Python 3.7 and 3.8 * Disable weakref types when targeting PyPy * Remove needless borrow from CallableProxy test * Add Borrowed variants of upgrade and upgrade exact to trait * Added tests for weakref borrow_upgrade methods * Change PyWeakRefMethods method names to be more consistent * Change weakref constructors to take PyAny for main target * Add track_caller to all panicing weakref methods * Add PyWeakRefMethods::upgrade*_as_unchecked * Fix PyWeakProxy and PyWeakCallableProxy Documentation * Replace deprecated wrap_pyfunction with bound equivalent * Add (Generic) PyWeakref Type * Reworked Proxy types into one (PyWeakrefProxy) * Rename PyWeakRef to PyWeakrefReference * Change PyWeakrefReference to only use type pointer when it exists * Remove `#[track_caller]` annotations for now * Make the gil-refs function feature dependent * Remove unused AsPyPointer import * Change docs links to PyNone to not include private module * Fix string based examples * Change tests to work for Python 3.13 * Fix cargo clippy for Python 3.13 --------- Co-authored-by: David Hewitt <mail@davidhewitt.dev>
This commit is contained in:
parent
d1a7cf400a
commit
25c1db4767
|
@ -0,0 +1 @@
|
||||||
|
Add `PyWeakref`, `PyWeakrefReference` and `PyWeakrefProxy`.
|
|
@ -49,3 +49,4 @@ pub use crate::types::string::PyStringMethods;
|
||||||
pub use crate::types::traceback::PyTracebackMethods;
|
pub use crate::types::traceback::PyTracebackMethods;
|
||||||
pub use crate::types::tuple::PyTupleMethods;
|
pub use crate::types::tuple::PyTupleMethods;
|
||||||
pub use crate::types::typeobject::PyTypeMethods;
|
pub use crate::types::typeobject::PyTypeMethods;
|
||||||
|
pub use crate::types::weakref::PyWeakrefMethods;
|
||||||
|
|
|
@ -47,6 +47,7 @@ pub use self::string::{PyString, PyString as PyUnicode, PyStringMethods};
|
||||||
pub use self::traceback::{PyTraceback, PyTracebackMethods};
|
pub use self::traceback::{PyTraceback, PyTracebackMethods};
|
||||||
pub use self::tuple::{PyTuple, PyTupleMethods};
|
pub use self::tuple::{PyTuple, PyTupleMethods};
|
||||||
pub use self::typeobject::{PyType, PyTypeMethods};
|
pub use self::typeobject::{PyType, PyTypeMethods};
|
||||||
|
pub use self::weakref::{PyWeakref, PyWeakrefMethods, PyWeakrefProxy, PyWeakrefReference};
|
||||||
|
|
||||||
/// Iteration over Python collections.
|
/// Iteration over Python collections.
|
||||||
///
|
///
|
||||||
|
@ -365,3 +366,4 @@ pub(crate) mod string;
|
||||||
pub(crate) mod traceback;
|
pub(crate) mod traceback;
|
||||||
pub(crate) mod tuple;
|
pub(crate) mod tuple;
|
||||||
pub(crate) mod typeobject;
|
pub(crate) mod typeobject;
|
||||||
|
pub(crate) mod weakref;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
pub use anyref::{PyWeakref, PyWeakrefMethods};
|
||||||
|
pub use proxy::PyWeakrefProxy;
|
||||||
|
pub use reference::PyWeakrefReference;
|
||||||
|
|
||||||
|
pub(crate) mod anyref;
|
||||||
|
pub(crate) mod proxy;
|
||||||
|
pub(crate) mod reference;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue