mirror of
https://github.com/python/cpython
synced 2026-09-29 08:45:29 +03:00
bpo-24643: Fix "#define timezone _timezone" clashes on Windows (GH-12019)
This commit is contained in:
parent
aadef2b416
commit
6673decfa0
3 changed files with 16 additions and 12 deletions
|
|
@ -38,6 +38,16 @@
|
|||
# include <sanitizer/msan_interface.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _Py_timezone _timezone
|
||||
#define _Py_daylight _daylight
|
||||
#define _Py_tzname _tzname
|
||||
#else
|
||||
#define _Py_timezone timezone
|
||||
#define _Py_daylight daylight
|
||||
#define _Py_tzname tzname
|
||||
#endif
|
||||
|
||||
#define SEC_TO_NS (1000 * 1000 * 1000)
|
||||
|
||||
/* Forward declarations */
|
||||
|
|
@ -1600,18 +1610,18 @@ init_timezone(PyObject *m)
|
|||
#ifdef HAVE_DECL_TZNAME
|
||||
PyObject *otz0, *otz1;
|
||||
tzset();
|
||||
PyModule_AddIntConstant(m, "timezone", timezone);
|
||||
PyModule_AddIntConstant(m, "timezone", _Py_timezone);
|
||||
#ifdef HAVE_ALTZONE
|
||||
PyModule_AddIntConstant(m, "altzone", altzone);
|
||||
#else
|
||||
PyModule_AddIntConstant(m, "altzone", timezone-3600);
|
||||
PyModule_AddIntConstant(m, "altzone", _Py_timezone-3600);
|
||||
#endif
|
||||
PyModule_AddIntConstant(m, "daylight", daylight);
|
||||
otz0 = PyUnicode_DecodeLocale(tzname[0], "surrogateescape");
|
||||
PyModule_AddIntConstant(m, "daylight", _Py_daylight);
|
||||
otz0 = PyUnicode_DecodeLocale(_Py_tzname[0], "surrogateescape");
|
||||
if (otz0 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape");
|
||||
otz1 = PyUnicode_DecodeLocale(_Py_tzname[1], "surrogateescape");
|
||||
if (otz1 == NULL) {
|
||||
Py_DECREF(otz0);
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue