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
{{ message }}
Repository navigation
Commit f930199
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: guide/src/migration.md
+46-6Lines changed: 46 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@ For a detailed list of all changes, see the [CHANGELOG](changelog.md).
7
7
8
8
### Removed implementations of `From<str::Utf8Error>`, `From<string::FromUtf16Error>`, and `From<char::DecodeUtf16Error>` for `PyErr`
9
9
10
+
<detailsopen>
11
+
<summary><small>Click to expand</small></summary>
12
+
10
13
Previously the implementations of `From<string::FromUtf8Error>`, `From<ffi::IntoStringError>`, `From<str::Utf8Error>`, `From<string::FromUtf16Error>`, and `From<char::DecodeUtf16Error>` failed to construct the correct Python exception class, as reported in <https://github.com/PyO3/pyo3/issues/5651>.
11
14
The implementations for `string::FromUtf8Error` and `ffi::IntoStringError` were fixed in this release.
For `string::FromUtf16Error` and `char::DecodeUtf16Error` the Rust error types do not contain any of the information required to construct a `UnicodeDecodeError`.
37
40
To raise a Python `UnicodeDecodeError` a new error should be manually constructed by calling `PyUnicodeDecodeError::new_err(...)`.
38
41
42
+
</details>
43
+
39
44
### `pyo3_build_config` APIs now require a direct dependency on `pyo3` or `pyo3-ffi`
40
45
46
+
<detailsopen>
47
+
<summary><small>Click to expand</small></summary>
48
+
41
49
Prior to PyO3 0.29, `pyo3-build-config` would inline part of the build configuration into the crate in its own build script.
42
50
This worked for simple builds but not for cross-compiling; `pyo3-ffi`'s build script would need to re-implement a lot of the same machinery to correctly configure the build for cross-compilation.
43
51
There were also edge cases where `pyo3-build-config` would use this inlined configuration incorrectly and misconfigure the build - e.g. [when cross compiling with `buck` or `bazel` build systems](https://github.com/PyO3/pyo3/issues/4579).
@@ -93,11 +101,43 @@ impl Sub {
93
101
}
94
102
```
95
103
104
+
</details>
105
+
106
+
### Minor API breaks for soundness reasons
107
+
108
+
<detailsopen>
109
+
<summary><small>Click to expand</small></summary>
110
+
111
+
Recent development in LLM-assisted security analysis has enhanced the ability to detect flaws, both for maintainers and attackers.
112
+
Such security analysis of PyO3 flagged some APIs with edge cases that could lead to unsoundness.
113
+
The PyO3 maintainers took the decision to make small breaking changes to eliminate these edge cases.
114
+
Users should not be affected by these changes unless they were inadvertently relying on unsound behavior.
115
+
116
+
The changes were:
117
+
118
+
-`PyCapsule::new_with_destructor` now requires the destructor to be `'static` to prevent possible use-after-free issues.
119
+
-`PyCFunction::new_closure` now requires the closure to be `Sync` to prevent possible thread unsafety. ⚠️ A security advisory will be issued for this, as the thread unsafety could easily go undetected in testing and lead to exploitable issues downstream in production. ⚠️
120
+
-`PyClassGuardMap` has been split into `PyClassGuardMap` and `PyClassGuardMapMut` to prevent possible lifetime variance issues.
121
+
-`PyClassGuardMut::as_super` now returns `PyClassGuardMutSuper` instead of `&mut PyClassGuardMut<SuperType>` to prevent possible type confusion issues.
122
+
123
+
</details>
124
+
125
+
### PyO3 now uses `raw-dylib` linking on Windows
126
+
127
+
<detailsopen>
128
+
<summary><small>Click to expand</small></summary>
129
+
130
+
The `raw-dylib` linking mode allows PyO3 to no longer need to have link libraries present when building for Windows targets.
131
+
This removes the need for the `generate-import-lib` feature (which is now a no-op) and generally simplifies building for Windows.
132
+
This is not expected to have negative impact on users, please report if there are issues.
133
+
134
+
</details>
135
+
96
136
## from 0.27.* to 0.28
97
137
98
138
### Default to supporting free-threaded Python
99
139
100
-
<detailsopen>
140
+
<details>
101
141
<summary><small>Click to expand</small></summary>
102
142
103
143
When PyO3 0.23 added support for free-threaded Python, this was as an opt-in feature for modules by annotating with `#[pymodule(gil_used = false)]`.
@@ -108,7 +148,7 @@ Modules now automatically allow use on free-threaded Python, unless they directl
108
148
109
149
### Deprecation of automatic `FromPyObject` for `#[pyclass]` types which implement `Clone`
110
150
111
-
<detailsopen>
151
+
<details>
112
152
<summary><small>Click to expand</small></summary>
113
153
114
154
`#[pyclass]` types which implement `Clone` used to also implement `FromPyObject` automatically.
@@ -151,7 +191,7 @@ The `#[pyclass(skip_from_py_object)]` option will eventually be deprecated and r
151
191
152
192
### Deprecation of `Py<T>` constructors from raw pointer
153
193
154
-
<detailsopen>
194
+
<details>
155
195
<summary><small>Click to expand</small></summary>
156
196
157
197
The constructors `Py::from_owned_ptr`, `Py::from_owned_ptr_or_opt`, and `Py::from_owned_ptr_or_err` (and similar "borrowed" variants) perform an unchecked cast to the `Py<T>` target type `T`.
### Removal of `From<Bound<'_, T>` and `From<Py<T>> for PyClassInitializer<T>`
195
235
196
-
<detailsopen>
236
+
<details>
197
237
<summary><small>Click to expand</small></summary>
198
238
199
239
As part of refactoring the initialization code these impls were removed and its functionality was moved into the generated code for `#[new]`.
@@ -227,7 +267,7 @@ let obj_2 = existing_bound.clone();
227
267
228
268
### Untyped buffer API moved to PyUntypedBuffer
229
269
230
-
<detailsopen>
270
+
<details>
231
271
<summary><small>Click to expand</small></summary>
232
272
233
273
`PyBuffer<T>` now is a typed wrapper around `PyUntypedBuffer`.
@@ -238,7 +278,7 @@ Users may need to update references to the moved functions.
238
278
239
279
### Internal change to use multi-phase initialization
240
280
241
-
<detailsopen>
281
+
<details>
242
282
<summary><small>Click to expand</small></summary>
243
283
244
284
[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