mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Change back to using unqualified tp_name, set __module__ attribute, explicitly add Py_TPFLAGS_HEAPTYPE → does not resolve DeprecationWarning :-(
This commit is contained in:
@@ -46,11 +46,7 @@ static PyMethodDef tp_methods_impl[]
|
||||
{nullptr, nullptr, 0, nullptr}};
|
||||
|
||||
// Note that this name is versioned.
|
||||
constexpr char tp_qualname_impl[] = PYBIND11_INTERNAL_MODULE_NAME
|
||||
"."
|
||||
"pybind11_detail_function_record_" PYBIND11_DETAIL_FUNCTION_RECORD_ABI_ID
|
||||
"_" PYBIND11_PLATFORM_ABI_ID;
|
||||
constexpr char tp_plainname_impl[]
|
||||
constexpr char tp_name_impl[]
|
||||
= "pybind11_detail_function_record_" PYBIND11_DETAIL_FUNCTION_RECORD_ABI_ID
|
||||
"_" PYBIND11_PLATFORM_ABI_ID;
|
||||
|
||||
@@ -76,10 +72,10 @@ PYBIND11_WARNING_DISABLE_CLANG("-Wmissing-field-initializers")
|
||||
PYBIND11_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
|
||||
#endif
|
||||
static PyType_Spec function_record_PyType_Spec
|
||||
= {function_record_PyTypeObject_methods::tp_qualname_impl,
|
||||
= {function_record_PyTypeObject_methods::tp_name_impl,
|
||||
sizeof(function_record_PyObject),
|
||||
0,
|
||||
Py_TPFLAGS_DEFAULT,
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
|
||||
function_record_PyType_Slots};
|
||||
PYBIND11_WARNING_POP
|
||||
|
||||
@@ -90,6 +86,7 @@ inline PyTypeObject *get_function_record_PyTypeObject() {
|
||||
if (type_obj == nullptr) {
|
||||
throw error_already_set();
|
||||
}
|
||||
setattr(type_obj, "__module__", str(PYBIND11_INTERNAL_MODULE_NAME));
|
||||
type = reinterpret_cast<PyTypeObject *>(type_obj);
|
||||
}
|
||||
return type;
|
||||
@@ -108,9 +105,7 @@ inline bool is_function_record_PyObject(PyObject *obj) {
|
||||
return true;
|
||||
}
|
||||
// This works across extension modules. Note that tp_name is versioned.
|
||||
if (strcmp(obj_type->tp_name, function_record_PyTypeObject_methods::tp_qualname_impl) == 0
|
||||
|| strcmp(obj_type->tp_name, function_record_PyTypeObject_methods::tp_plainname_impl)
|
||||
== 0) {
|
||||
if (strcmp(obj_type->tp_name, frtype->tp_name) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user