[issue15870] PyType_FromSpec should take metaclass as an argument

Steve Dower report at bugs.python.org
Mon Sep 27 15:16:29 EDT 2021


Steve Dower <steve.dower at python.org> added the comment:

The section of documentation you reference explains that this behaviour is  not covered by the standard ("applied to a non-static variable like PyBaseObject_Type() is not required to produce an address constant"), and so static addresses of exported symbols do not have to be supported.

It also says that gcc supports it (I assume by generating dynamic code for getting the address) while MSVC does not (requiring you to write your own dynamic code). 

The conclusion, "tp_base should be set in the extension module’s init function," is exactly the right conclusion if you want your code to work across all the supported compilers. Invoking the C standard to explain why this looks similar to standard code but actually is not is totally fine.

Though I do note that the text can obviously be clearer. I assume it was written this way because of a discussion that started "but the C standard says ..." and so it was clarified to point out that this isn't actually the part of the spec that someone thought it was. If we can make it clearer, happy to, but it's certainly not incorrect as it stands.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue15870>
_______________________________________


More information about the Python-bugs-list mailing list