Skip to content

timemodule.c does not handle errors on module creation #111295

Closed
@sobolevn

Description

@sobolevn

Bug report

Here are the problematic lines:

cpython/Modules/timemodule.c

Lines 1766 to 1772 in 8b44f3c

PyModule_AddIntConstant(m, "timezone", _Py_timezone);
#ifdef HAVE_ALTZONE
PyModule_AddIntConstant(m, "altzone", altzone);
#else
PyModule_AddIntConstant(m, "altzone", _Py_timezone-3600);
#endif
PyModule_AddIntConstant(m, "daylight", _Py_daylight);

cpython/Modules/timemodule.c

Lines 1831 to 1833 in 8b44f3c

PyModule_AddIntConstant(m, "timezone", julyzone);
PyModule_AddIntConstant(m, "altzone", janzone);
PyModule_AddIntConstant(m, "daylight", janzone != julyzone);

cpython/Modules/timemodule.c

Lines 1836 to 1838 in 8b44f3c

PyModule_AddIntConstant(m, "timezone", janzone);
PyModule_AddIntConstant(m, "altzone", julyzone);
PyModule_AddIntConstant(m, "daylight", janzone != julyzone);

However, in some cases it uses the correct approach:

cpython/Modules/timemodule.c

Lines 1985 to 1987 in 8b44f3c

if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC) < 0) {
return -1;
}

Linked PRs

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions