Those currently marked as unsupported, despite being part of the Limited API. And it looks, according to the docs, implementations should be possible. Or I miss something obvious?
PyType_GetModuleName
Return the type's module name. Equivalent to getting the :attr:type.__module__ attribute.
Possible implementation:
PyObject *
PyType_GetModuleName(PyTypeObject *type)
{
return PyObject_GetAttrString((PyObject *)type, "__module__");
}
PyType_GetFullyQualifiedName
Return the type's fully qualified name. Equivalent to f"{type.__module__}.{type.__qualname__}", or :attr:type.__qualname__ if :attr:type.__module__ is not a string or is equal to "builtins".
(Looking on the actual code, it seems that docs are inaccurate as the alternative happens also if a string is equal to __main__.)
Possible implementation:
PyObject *
PyType_GetFullyQualifiedName(PyTypeObject *type)
{
PyObject *qualname = PyType_GetQualName(type);
if (qualname == NULL) {
return NULL;
}
PyObject *module = PyType_GetModuleName(type);
if (module == NULL) {
Py_DECREF(qualname);
return NULL;
}
PyObject *result;
if (PyUnicode_Check(module)
&& !PyUnicode_EqualToUTF8(module, "builtins")
&& !PyUnicode_EqualToUTF8(module, "__main__"))
{
result = PyUnicode_FromFormat("%U.%U", module, qualname);
}
else {
result = Py_NewRef(qualname);
}
Py_DECREF(module);
Py_DECREF(qualname);
return result;
}
Those currently marked as unsupported, despite being part of the Limited API. And it looks, according to the docs, implementations should be possible. Or I miss something obvious?
PyType_GetModuleName
Possible implementation:
PyType_GetFullyQualifiedName
(Looking on the actual code, it seems that docs are inaccurate as the alternative happens also if a string is equal to
__main__.)Possible implementation: