]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-24643: Fix "GH-define timezone _timezone" clashes on Windows (GH-12019)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 26 Feb 2019 00:15:04 +0000 (16:15 -0800)
committerGitHub <noreply@github.com>
Tue, 26 Feb 2019 00:15:04 +0000 (16:15 -0800)
(cherry picked from commit 6673decfa0fb078f60587f5cb5e98460eea137c2)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Misc/NEWS.d/next/Windows/2019-02-24-07-52-39.bpo-24643.PofyiS.rst [new file with mode: 0644]
Modules/timemodule.c
PC/pyconfig.h

diff --git a/Misc/NEWS.d/next/Windows/2019-02-24-07-52-39.bpo-24643.PofyiS.rst b/Misc/NEWS.d/next/Windows/2019-02-24-07-52-39.bpo-24643.PofyiS.rst
new file mode 100644 (file)
index 0000000..7bc62d8
--- /dev/null
@@ -0,0 +1 @@
+Fix name collisions due to ``#define timezone _timezone`` in PC/pyconfig.h.
index bbfb7db7abde93e3ce6fb10cd2409edb898c3395..ae7de5b2c7664086c0782b925e7341bc9ada9618 100644 (file)
 # 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 */
@@ -1554,18 +1564,18 @@ init_timezone(PyObject *m)
 #if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__)
     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;
index bb9171fbcb7db64afd4b845550978d2ac9d8b817..46fc84e92f29ec2bee62f01124c6f34ae947e997 100644 (file)
@@ -192,13 +192,6 @@ typedef int pid_t;
 #define Py_IS_FINITE(X) _finite(X)
 #define copysign _copysign
 
-/* VS 2015 defines these names with a leading underscore */
-#if _MSC_VER >= 1900
-#define timezone _timezone
-#define daylight _daylight
-#define tzname _tzname
-#endif
-
 /* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/
 #if _MSC_VER >= 1400 && _MSC_VER < 1600
 #define HAVE_SXS 1