You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guide/src/migration.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,52 @@ let obj_2 = existing_bound.clone();
88
88
# })
89
89
```
90
90
91
+
### Deprecation of super class initialization from tuples
92
+
93
+
Performing superclass initialitation from a subclass via a tuple is deprecated and will be removed in a future PyO3 version.
94
+
This also includes the `From<(S, B)> for PyClassInitializer<S>` impl which we can't warn against.
95
+
To migrate use `PyClassInitializer` directly:
96
+
97
+
Before:
98
+
99
+
```rust
100
+
# #![allow(deprecated)]
101
+
# usepyo3::prelude::*;
102
+
#[pyclass(subclass)]
103
+
structBase;
104
+
105
+
#[pyclass(extends=Base)]
106
+
structSub;
107
+
108
+
#[pymethods]
109
+
implSub {
110
+
#[new]
111
+
fnnew() -> (Self, Base) {
112
+
(Self, Base)
113
+
}
114
+
}
115
+
```
116
+
117
+
After:
118
+
119
+
```rust
120
+
# usepyo3::prelude::*;
121
+
#[pyclass(subclass)]
122
+
structBase;
123
+
124
+
#[pyclass(extends=Base)]
125
+
structSub;
126
+
127
+
#[pymethods]
128
+
implSub {
129
+
#[new]
130
+
fnnew() ->PyClassInitializer<Self> {
131
+
PyClassInitializer::from(Base)
132
+
.add_subclass(Self)
133
+
}
134
+
}
135
+
```
136
+
91
137
### Internal change to use multi-phase initialization
92
138
93
139
[PEP 489](https://peps.python.org/pep-0489/) introduced "multi-phase initialization" for extension modules which provides ways to allocate and clean up per-module state.
0 commit comments