This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Docs are incorrect re: constant initialization in the C99 standard
Type: Stage:
Components: Documentation Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, jhaberman
Priority: normal Keywords:

Created on 2021-09-28 00:24 by jhaberman, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg402752 - (view) Author: Josh Haberman (jhaberman) Date: 2021-09-28 00:24
I believe the following excerpt from the docs is incorrect (

> Slot initialization is subject to the rules of initializing
> globals. C99 requires the initializers to be “address
> constants”. Function designators like PyType_GenericNew(),
> with implicit conversion to a pointer, are valid C99 address
> constants.
> However, the unary ‘&’ operator applied to a non-static
> variable like PyBaseObject_Type() is not required to produce
> an address constant. Compilers may support this (gcc does),
> MSVC does not. Both compilers are strictly standard
> conforming in this particular behavior.
> Consequently, tp_base should be set in the extension module’s init function.

I explained why in and on

The short version: &foo is an "address constant" according to the standard whenever "foo" has static storage duration.  Variables declared "extern" have static storage duration. Therefore strictly conforming implementations should accept &PyBaseObject_Type as a valid constant initializer.

I believe the text above could be replaced by something like:

> MSVC does not support constant initialization of of an address
> that comes from another DLL, so extensions should be set in the
> extension module's init function.
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89469
2021-09-28 00:24:44jhabermancreate