On Thu, Jun 13, 2019 at 2:35 PM Joe Jevnik via capi-sig <capi-sig@python.org> wrote:
I created an issue and added a PR that I believe covers all of the unmanaged memory. The only thing I know is still unmanaged is the PyGetSetDef closure, but I am not sure what to do about that. Also, users can opt-out of that API so it's less of an issue.
We encountered a similar issue when switching PyStructureSequence_NewType to use PyType_FromSpec. My colleague Eddie Elizondo put together the pull request that made that change and you can see where we were affected by the same issue with statically allocated data in PyType_Spec and PyMemberDef
https://github.com/python/cpython/pull/9665/files
Our internal version uses the same trick you propose to assign PyUnicode_AsUTF8 to tp_name and it works well. That should find its way upstream.