2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 04:42:28 +00:00

Safer pickle support (explicit auto_pickle parameter)

[SVN r9313]
This commit is contained in:
Ralf W. Grosse-Kunstleve
2001-02-22 20:47:36 +00:00
parent d8d2a900f6
commit abbf219e75

View File

@@ -99,6 +99,13 @@ namespace {
return tuple(instance_class, initargs, state);
}
ref auto_pickle(PyObject_GetAttrString(instance_class.get(), const_cast<char*>("__auto_pickle__")), ref::null_ok);
PyErr_Clear();
if (auto_pickle.get() == 0) {
PyErr_SetString(PyExc_AttributeError, "auto_pickle not enabled");
throw error_already_set();
}
ref state(PyObject_GetAttrString(obj, const_cast<char*>("__dict__")), ref::null_ok);
PyErr_Clear();
if (state.get() != 0 && dictionary(state).size() > 0)