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/pyclass-parameters.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,6 @@
23
23
|`sequence`| Inform PyO3 that this class is a [`Sequence`][params-sequence], and so leave its C-API mapping length slot empty. |
24
24
|`set_all`| Generates setters for all fields of the pyclass. |
25
25
|`new = "from_fields"`| Generates a default `__new__` constructor with all fields as parameters in the `new()` method. |
26
-
|`skip_from_py_object`| Prevents this PyClass from participating in the `FromPyObject: PyClass + Clone` blanket implementation. This allows a custom `FromPyObject` impl, even if `self` is `Clone`. |
27
26
|`str`| Implements `__str__` using the `Display` implementation of the underlying Rust datatype or by passing an optional format string `str="<format string>"`. *Note: The optional format string is only allowed for structs. `name` and `rename_all` are incompatible with the optional format string. Additional details can be found in the discussion on this [PR](https://github.com/PyO3/pyo3/pull/4233).*|
28
27
|`subclass`| Allows other Python classes and `#[pyclass]` to inherit from this class. Enums cannot be subclassed. |
29
28
|`unsendable`| Required if your struct is not [`Send`][params-3]. Rather than using `unsendable`, consider implementing your struct in a thread-safe way by e.g. substituting [`Rc`][params-4] with [`Arc`][params-5]. By using `unsendable`, your class will panic when accessed by another thread. Also note the Python's GC is multi-threaded and while unsendable classes will not be traversed on foreign threads to avoid UB, this can lead to memory leaks. |
Copy file name to clipboardExpand all lines: guide/src/conversions/traits.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -525,7 +525,7 @@ Over the next few releases the blanket implementation is gradually phased out, a
525
525
As a first step of this migration a new `skip_from_py_object` option for `#[pyclass]` was introduced, to opt-out of the blanket implementation and allow downstream users to provide their own implementation:
526
526
527
527
```rust
528
-
# #![allow(dead_code)]
528
+
# #![allow(dead_code, deprecated)]
529
529
# usepyo3::prelude::*;
530
530
531
531
#[pyclass(skip_from_py_object)] // opt-out of the PyO3 FromPyObject blanket
@@ -548,6 +548,10 @@ impl<'py> FromPyObject<'_, 'py> for Number {
548
548
As a second step the `from_py_object` option was introduced.
549
549
This option also opts-out of the blanket implementation and instead generates a custom `FromPyObject` implementation for the pyclass which is functionally equivalent to the blanket.
550
550
551
+
As of PyO3 0.30.0 `skip_from_py_object` is the new default behavior.
552
+
Setting the option is now deprecated and can be safely removed without changes in behavior.
553
+
PyO3 will remove this option entirely in a future release.
554
+
551
555
## `IntoPyObject`
552
556
553
557
The [`IntoPyObject`] trait defines the to-python conversion for a Rust type.
note = "The `FromPyObject` implementation for `#[pyclass]` types which implement `Clone` is changing to an opt-in option. Use `#[pyclass(from_py_object)]` to opt-in to the `FromPyObject` derive now, or `#[pyclass(skip_from_py_object)]` to skip the `FromPyObject` implementation."
7
-
)]
8
-
pubconstMSG:() = ();
9
-
}
10
-
11
-
implHasAutomaticFromPyObject<false>{
12
-
pubconstMSG:() = ();
13
-
}
1
+
#[deprecated(
2
+
since = "0.30.0",
3
+
note = "`skip_from_py_object` enabled by default. The option will be removed in the future"
0 commit comments