App: fixes #10460: App::PropertyPythonObject is not saving data
Since Py3.11 the methods names __setstate__ and __getstate__ conflict with the method names added to the object class. Thus rename them to 'loads' and 'dumps'
This commit is contained in:
@@ -87,9 +87,9 @@ std::string PropertyPythonObject::toString() const
|
||||
throw Py::Exception();
|
||||
Py::Callable method(pickle.getAttr(std::string("dumps")));
|
||||
Py::Object dump;
|
||||
if (this->object.hasAttr("__getstate__")) {
|
||||
if (this->object.hasAttr("dumps")) {
|
||||
Py::Tuple args;
|
||||
Py::Callable state(this->object.getAttr("__getstate__"));
|
||||
Py::Callable state(this->object.getAttr("dumps"));
|
||||
dump = state.apply(args);
|
||||
}
|
||||
else if (this->object.hasAttr("__dict__")) {
|
||||
@@ -129,10 +129,10 @@ void PropertyPythonObject::fromString(const std::string& repr)
|
||||
args.setItem(0, Py::String(repr));
|
||||
Py::Object res = method.apply(args);
|
||||
|
||||
if (this->object.hasAttr("__setstate__")) {
|
||||
if (this->object.hasAttr("loads")) {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, res);
|
||||
Py::Callable state(this->object.getAttr("__setstate__"));
|
||||
Py::Callable state(this->object.getAttr("loads"));
|
||||
state.apply(args);
|
||||
}
|
||||
else if (this->object.hasAttr("__dict__")) {
|
||||
|
||||
Reference in New Issue
Block a user