File tree 3 files changed +16
-10
lines changed 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -2193,7 +2193,7 @@ impl<'py> PyAnyMethods<'py> for Bound<'py, PyAny> {
2193
2193
2194
2194
#[ cfg( not( PyPy ) ) ]
2195
2195
fn py_super ( & self ) -> PyResult < Bound < ' py , PySuper > > {
2196
- PySuper :: new2 ( Bound :: borrowed_from_gil_ref ( & self . get_type ( ) ) , self )
2196
+ PySuper :: new_bound ( Bound :: borrowed_from_gil_ref ( & self . get_type ( ) ) , self )
2197
2197
}
2198
2198
}
2199
2199
Original file line number Diff line number Diff line change @@ -16,6 +16,19 @@ pyobject_native_type_core!(
16
16
) ;
17
17
18
18
impl PySuper {
19
+ /// Deprecated form of `PySuper::new_bound`.
20
+ #[ deprecated(
21
+ since = "0.21.0" ,
22
+ note = "`PySuper::new` will be replaced by `PySuper::new_bound` in a future PyO3 version"
23
+ ) ]
24
+ pub fn new < ' py > ( ty : & ' py PyType , obj : & ' py PyAny ) -> PyResult < & ' py PySuper > {
25
+ Self :: new_bound (
26
+ Bound :: borrowed_from_gil_ref ( & ty) ,
27
+ Bound :: borrowed_from_gil_ref ( & obj) ,
28
+ )
29
+ . map ( Bound :: into_gil_ref)
30
+ }
31
+
19
32
/// Constructs a new super object. More read about super object: [docs](https://docs.python.org/3/library/functions.html#super)
20
33
///
21
34
/// # Examples
@@ -56,15 +69,7 @@ impl PySuper {
56
69
/// }
57
70
/// }
58
71
/// ```
59
- pub fn new < ' py > ( ty : & ' py PyType , obj : & ' py PyAny ) -> PyResult < & ' py PySuper > {
60
- Self :: new2 (
61
- Bound :: borrowed_from_gil_ref ( & ty) ,
62
- Bound :: borrowed_from_gil_ref ( & obj) ,
63
- )
64
- . map ( Bound :: into_gil_ref)
65
- }
66
-
67
- pub ( crate ) fn new2 < ' py > (
72
+ pub fn new_bound < ' py > (
68
73
ty : & Bound < ' py , PyType > ,
69
74
obj : & Bound < ' py , PyAny > ,
70
75
) -> PyResult < Bound < ' py , PySuper > > {
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ impl SubClass {
35
35
}
36
36
37
37
fn method_super_new ( self_ : & PyCell < Self > ) -> PyResult < & PyAny > {
38
+ #[ allow( deprecated) ]
38
39
let super_ = PySuper :: new ( self_. get_type ( ) , self_) ?;
39
40
super_. call_method ( "method" , ( ) , None )
40
41
}
You can’t perform that action at this time.
0 commit comments