Skip to content

More readable module constant addition statement #127435

@rruuaanng

Description

@rruuaanng

Feature or enhancement

Proposal:

I would like to ask if we need to package the addition of macro and constant for some modules in Modules/*? I think they should be like socketmodule.c, maybe it will be better. If allowed, I'll submit the PR. Like this:

#define ADD_INT_MACRO(MOD, INT) do {                    \
    if (PyModule_AddIntConstant(MOD, #INT, INT) < 0) {  \
        goto error;                                     \
    }                                                   \
} while (0)

#ifdef AF_APPLETALK
    /* Appletalk DDP */
    ADD_INT_MACRO(m, AF_APPLETALK);
#endif

for example:
from posixmodule.c

#ifdef TMP_MAX
    if (PyModule_AddIntMacro(m, TMP_MAX)) return -1;
#endif
#ifdef WCONTINUED
    if (PyModule_AddIntMacro(m, WCONTINUED)) return -1;
#endif

from symtablemodule.c

if (PyModule_AddIntMacro(m, USE) < 0) return -1;
if (PyModule_AddIntMacro(m, DEF_GLOBAL) < 0) return -1;

I'm not sure if this is a cosmetic change, but I think it's necessary since there are only a few old modules that don't have this.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirpendingThe issue will be closed if no feedback is providedtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions