diff options
Diffstat (limited to 'sources/shiboken2/libshiboken/pep384impl.cpp')
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index 5e0053e2e..4149bbcbf 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -78,14 +78,20 @@ static PyGetSetDef probe_getseters[] = { {nullptr} /* Sentinel */ }; +static PyMemberDef probe_members[] = { + {nullptr} /* Sentinel */ +}; + #define probe_tp_dealloc make_dummy(1) #define probe_tp_repr make_dummy(2) #define probe_tp_call make_dummy(3) +#define probe_tp_getattro make_dummy(16) #define probe_tp_str make_dummy(4) #define probe_tp_traverse make_dummy(5) #define probe_tp_clear make_dummy(6) #define probe_tp_iternext make_dummy(7) #define probe_tp_methods probe_methoddef +#define probe_tp_members probe_members #define probe_tp_getset probe_getseters #define probe_tp_descr_get make_dummy(10) #define probe_tp_init make_dummy(11) @@ -101,11 +107,13 @@ static PyType_Slot typeprobe_slots[] = { {Py_tp_dealloc, probe_tp_dealloc}, {Py_tp_repr, probe_tp_repr}, {Py_tp_call, probe_tp_call}, + {Py_tp_getattro, probe_tp_getattro}, {Py_tp_str, probe_tp_str}, {Py_tp_traverse, probe_tp_traverse}, {Py_tp_clear, probe_tp_clear}, {Py_tp_iternext, probe_tp_iternext}, {Py_tp_methods, probe_tp_methods}, + {Py_tp_members, probe_tp_members}, {Py_tp_getset, probe_tp_getset}, {Py_tp_descr_get, probe_tp_descr_get}, {Py_tp_init, probe_tp_init}, @@ -144,6 +152,7 @@ check_PyTypeObject_valid() || probe_tp_dealloc != check->tp_dealloc || probe_tp_repr != check->tp_repr || probe_tp_call != check->tp_call + || probe_tp_getattro != check->tp_getattro || probe_tp_str != check->tp_str || probe_tp_traverse != check->tp_traverse || probe_tp_clear != check->tp_clear @@ -427,27 +436,6 @@ PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals) #endif // Py_LIMITED_API -// This is only a simple local helper that returns a computed variable. -// Used also in Python 2. -#if defined(Py_LIMITED_API) || defined(IS_PY2) -static PyObject * -PepRun_GetResult(const char *command) -{ - PyObject *d, *v, *res; - - d = PyDict_New(); - if (d == nullptr - || PyDict_SetItem(d, Shiboken::PyMagicName::builtins(), PyEval_GetBuiltins()) < 0) { - return nullptr; - } - v = PyRun_String(command, Py_file_input, d, d); - res = v ? PyDict_GetItem(d, Shiboken::PyName::result()) : nullptr; - Py_XDECREF(v); - Py_DECREF(d); - return res; -} -#endif // defined(Py_LIMITED_API) || defined(IS_PY2) - /***************************************************************************** * * Support for classobject.h @@ -669,6 +657,29 @@ PyImport_GetModule(PyObject *name) #endif // PY_VERSION_HEX < 0x03070000 || defined(Py_LIMITED_API) +// 2020-06-16: For simplicity of creating arbitrary things, this function +// is now made public. + +PyObject * +PepRun_GetResult(const char *command) +{ + /* + * Evaluate a string and return the variable `result` + */ + PyObject *d, *v, *res; + + d = PyDict_New(); + if (d == nullptr + || PyDict_SetItem(d, Shiboken::PyMagicName::builtins(), PyEval_GetBuiltins()) < 0) { + return nullptr; + } + v = PyRun_String(command, Py_file_input, d, d); + res = v ? PyDict_GetItem(d, Shiboken::PyName::result()) : nullptr; + Py_XDECREF(v); + Py_DECREF(d); + return res; +} + /***************************************************************************** * * Python 2 incompatibilities |