pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/111296/files

media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-2d31826944fd3be8.css" /> gh-111295: Fix timemodule.c not checking for errors when initializing by sobolevn · Pull Request #111296 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`time` not checking for errors when initializing.
27 changes: 17 additions & 10 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,12 @@ get_gmtoff(time_t t, struct tm *p)
static int
init_timezone(PyObject *m)
{
#define ADD_INT(NAME, VALUE) do { \
if (PyModule_AddIntConstant(m, NAME, VALUE) < 0) { \
return -1; \
} \
} while (0)

assert(!PyErr_Occurred());

/* This code moved from PyInit_time wholesale to allow calling it from
Expand All @@ -1763,13 +1769,13 @@ init_timezone(PyObject *m)
#if !defined(MS_WINDOWS) || defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
tzset();
#endif
PyModule_AddIntConstant(m, "timezone", _Py_timezone);
ADD_INT("timezone", _Py_timezone);
#ifdef HAVE_ALTZONE
PyModule_AddIntConstant(m, "altzone", altzone);
ADD_INT("altzone", altzone);
#else
PyModule_AddIntConstant(m, "altzone", _Py_timezone-3600);
ADD_INT("altzone", _Py_timezone-3600);
#endif
PyModule_AddIntConstant(m, "daylight", _Py_daylight);
ADD_INT("daylight", _Py_daylight);
#ifdef MS_WINDOWS
TIME_ZONE_INFORMATION tzinfo = {0};
GetTimeZoneInformation(&tzinfo);
Expand Down Expand Up @@ -1828,20 +1834,21 @@ init_timezone(PyObject *m)
PyObject *tzname_obj;
if (janzone < julyzone) {
/* DST is reversed in the southern hemisphere */
PyModule_AddIntConstant(m, "timezone", julyzone);
PyModule_AddIntConstant(m, "altzone", janzone);
PyModule_AddIntConstant(m, "daylight", janzone != julyzone);
ADD_INT("timezone", julyzone);
ADD_INT("altzone", janzone);
ADD_INT("daylight", janzone != julyzone);
tzname_obj = Py_BuildValue("(zz)", julyname, janname);
} else {
PyModule_AddIntConstant(m, "timezone", janzone);
PyModule_AddIntConstant(m, "altzone", julyzone);
PyModule_AddIntConstant(m, "daylight", janzone != julyzone);
ADD_INT("timezone", janzone);
ADD_INT("altzone", julyzone);
ADD_INT("daylight", janzone != julyzone);
tzname_obj = Py_BuildValue("(zz)", janname, julyname);
}
if (PyModule_Add(m, "tzname", tzname_obj) < 0) {
return -1;
}
#endif // !HAVE_DECL_TZNAME
#undef ADD_INT

if (PyErr_Occurred()) {
return -1;
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy