Title: [C API] PyType_GetSlot cannot get tp_name
Type: enhancement Stage:
Components: C API Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: corona10, fancitron, petr.viktorin
Priority: normal Keywords:

Created on 2020-10-14 13:52 by fancitron, last changed 2020-10-20 09:10 by petr.viktorin.

Messages (3)
msg378616 - (view) Author: (fancitron) Date: 2020-10-14 13:52
In the Limited API (where PyTypeObject is opaque), there is no way to retrieve the tp_name of a type object.  The PyType_GetSlot() function doesn’t define a slot ID Py_tp_name.  This makes it inconvenient to port existing code to the Limited API.  Is this intentional?  How to work around this?
msg379102 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2020-10-20 08:20
The slots are originally intended for defining types (PyType_FromSpec); PyType_GetSlot is not as useful as it could be.
tp_name can be exposed, but it needs to also be handled properly PyType_FromSpec -- e.g. raise an error.
msg379109 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2020-10-20 09:10
Ah, scratch that: PyType_GetSlot returns a function pointer.
To be correct, we should to expose a new function like PyType_GetName.

It's true that CPython currently doesn't always honor the distinction between data and function pointers, but the C standard says they're distinct, so it might bite us in the future.
Date User Action Args
2020-10-20 09:10:50petr.viktorinsetmessages: + msg379109
2020-10-20 08:20:20petr.viktorinsetmessages: + msg379102
2020-10-14 13:55:04vstinnersetnosy: + petr.viktorin, corona10

title: PyType_GetSlot cannot get tp_name -> [C API] PyType_GetSlot cannot get tp_name
2020-10-14 13:52:05fancitroncreate