Revert "Disable segfaulty subclassing by default"
This reverts commit 5096f936dc
.
This commit is contained in:
parent
3dc5b86f22
commit
0a84c201f7
|
@ -57,9 +57,6 @@ extension-module = []
|
||||||
# are welcome.
|
# are welcome.
|
||||||
# abi3 = []
|
# abi3 = []
|
||||||
|
|
||||||
# Activate subclassing support
|
|
||||||
unsound-subclass = ["pyo3cls/unsound-subclass"]
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"pyo3cls",
|
"pyo3cls",
|
||||||
|
|
|
@ -9,7 +9,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies.pyo3]
|
[dependencies.pyo3]
|
||||||
path = "../../"
|
path = "../../"
|
||||||
features = ["extension-module", "unsound-subclass"]
|
features = ["extension-module"]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "rustapi_module"
|
name = "rustapi_module"
|
||||||
|
|
|
@ -173,10 +173,10 @@ so that they can benefit from a freelist. `XXX` is a number of items for the fre
|
||||||
If a custom class contains references to other Python objects that can be collected, the `PyGCProtocol` trait has to be implemented.
|
If a custom class contains references to other Python objects that can be collected, the `PyGCProtocol` trait has to be implemented.
|
||||||
* `weakref` - Adds support for Python weak references.
|
* `weakref` - Adds support for Python weak references.
|
||||||
* `extends=BaseType` - Use a custom base class. The base `BaseType` must implement `PyTypeInfo`.
|
* `extends=BaseType` - Use a custom base class. The base `BaseType` must implement `PyTypeInfo`.
|
||||||
|
* `subclass` - Allows Python classes to inherit from this class.
|
||||||
* `dict` - Adds `__dict__` support, so that the instances of this type have a dictionary containing arbitrary instance variables.
|
* `dict` - Adds `__dict__` support, so that the instances of this type have a dictionary containing arbitrary instance variables.
|
||||||
* `module="XXX"` - Set the name of the module the class will be shown as defined in. If not given, the class
|
* `module="XXX"` - Set the name of the module the class will be shown as defined in. If not given, the class
|
||||||
will be a virtual member of the `builtins` module.
|
will be a virtual member of the `builtins` module.
|
||||||
* `subclass` - Allows Python classes to inherit from this class. This feature is hidden behind a `unsound-subclass` feature because it is currently causing segmentation faults
|
|
||||||
|
|
||||||
## Constructor
|
## Constructor
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,3 @@ edition = "2018"
|
||||||
quote = "1"
|
quote = "1"
|
||||||
proc-macro2 = "1"
|
proc-macro2 = "1"
|
||||||
syn = { version = "1", features = ["full", "extra-traits"] }
|
syn = { version = "1", features = ["full", "extra-traits"] }
|
||||||
|
|
||||||
[features]
|
|
||||||
unsound-subclass = []
|
|
||||||
|
|
|
@ -136,12 +136,6 @@ impl PyClassArgs {
|
||||||
parse_quote! {pyo3::type_flags::WEAKREF}
|
parse_quote! {pyo3::type_flags::WEAKREF}
|
||||||
}
|
}
|
||||||
"subclass" => {
|
"subclass" => {
|
||||||
if cfg!(not(feature = "unsound-subclass")) {
|
|
||||||
return Err(syn::Error::new_spanned(
|
|
||||||
exp.path.clone(),
|
|
||||||
"You need to activate the `unsound-subclass` feature if you want to use subclassing",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
parse_quote! {pyo3::type_flags::BASETYPE}
|
parse_quote! {pyo3::type_flags::BASETYPE}
|
||||||
}
|
}
|
||||||
"dict" => {
|
"dict" => {
|
||||||
|
|
|
@ -18,6 +18,3 @@ quote = "1"
|
||||||
proc-macro2 = "1"
|
proc-macro2 = "1"
|
||||||
syn = { version = "1", features = ["full", "extra-traits"] }
|
syn = { version = "1", features = ["full", "extra-traits"] }
|
||||||
pyo3-derive-backend = { path = "../pyo3-derive-backend", version = "=0.8.5" }
|
pyo3-derive-backend = { path = "../pyo3-derive-backend", version = "=0.8.5" }
|
||||||
|
|
||||||
[features]
|
|
||||||
unsound-subclass = ["pyo3-derive-backend/unsound-subclass"]
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::py_run;
|
use pyo3::py_run;
|
||||||
|
|
||||||
#[cfg(feature = "unsound-subclass")]
|
|
||||||
use pyo3::types::IntoPyDict;
|
use pyo3::types::IntoPyDict;
|
||||||
|
|
||||||
use pyo3::types::{PyDict, PySet};
|
use pyo3::types::{PyDict, PySet};
|
||||||
|
@ -13,11 +12,9 @@ struct BaseClass {
|
||||||
val1: usize,
|
val1: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unsound-subclass")]
|
|
||||||
#[pyclass(subclass)]
|
#[pyclass(subclass)]
|
||||||
struct SubclassAble {}
|
struct SubclassAble {}
|
||||||
|
|
||||||
#[cfg(feature = "unsound-subclass")]
|
|
||||||
#[test]
|
#[test]
|
||||||
fn subclass() {
|
fn subclass() {
|
||||||
let gil = Python::acquire_gil();
|
let gil = Python::acquire_gil();
|
||||||
|
|
Loading…
Reference in New Issue