[issue42035] [C API] PyType_GetSlot cannot get tp_name
Petr Viktorin
report at bugs.python.org
Tue Jan 19 11:43:23 EST 2021
Petr Viktorin <encukou at gmail.com> added the comment:
Now that I see the implementation (and now that I'm spending a lot of time trying to formalize what is good stable API), I see a problem with PyType_GetName: it effectively returns a borrowed reference.
The proposed docs say:
Callers can hold [the retuned] pointer until the type has been deallocated.
This is not friendly to alternate Python implementations. For example, if tp_name is stored as UTF-32, it would need to generate the char* data -- and then retain it until the class is deallocated.
I guess the "correct" way would be to return a Py_buffer, which would (in CPython) reference the class.
Victor, what do you think?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42035>
_______________________________________
More information about the Python-bugs-list
mailing list