msg246803 - (view) |
Author: James Salter (James Salter) * |
Date: 2015-07-16 13:51 |
For python 3.5, PC/pyconfig.h contains the following for vs2015 support: /* VS 2015 defines these names with a leading underscore */ #if _MSC_VER >= 1900 #define timezone _timezone #define daylight _daylight #define tzname _tzname #endif This breaks any python extension code that includes pyconfig.h and then defines any function or variable called 'timezone', 'daylight', or 'tzname'. My breaking case is a conflict with <ucrt/sys/timeb.h> from the Windows 10 kit (for me: c:\program files (x86)\Windows Kits\10\include\10.0.10056.0\ucrt\sys\timeb.h). This is used during compilation of gevent, which includes that file via libev/ev_win32.c. timeb.h contains this innocent structure: struct __timeb32 { __time32_t time; unsigned short millitm; short timezone; short dstflag; }; I think we need a different approach that doesn't conflict with common english variable names and in particular other windows SDK includes. |
|
|
msg246804 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2015-07-16 14:14 |
I suppose we'll have to resort to #ifndef _Py_timezone #if _MSC_VER >= 1900 #define _Py_timezone _timezone #else #define _Py_timezone timezone #endif #endif ... |
|
|
msg246805 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2015-07-16 14:26 |
Or we could define _timezone on those platforms that don't have the underscore. I'm not hugely fussed either way. We need to fix this though. |
|
|
msg246806 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2015-07-16 15:05 |
Can't we move the #define only in .c files where they are needed? Or in a private header (not included by Python.h)? |
|
|
msg246807 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2015-07-16 15:37 |
That's probably an option, though it would break extensions that use `timezone` expecting it to work. But it seems like any change is going to cause that. I prefer defining _Py_timezone, since at least we can offer something that is portable for all Python 3.5 platforms (that support timezones), unlike timezone/_timezone (MSVC deprecated `timezone` a few versions ago and has just removed it completely, hence the breakage). |
|
|
msg246817 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2015-07-16 20:08 |
> That's probably an option, though it would break extensions that use `timezone` expecting it to work. Hum, I don't remember that the "timezone" symbol of part of the Python public API. Which extensions? |
|
|
msg246820 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2015-07-16 20:26 |
It's not, but "#include <python.h>" in any extension will make it available for you, so it's very likely that extensions have simply used it without adding their own conditional compilation for the various interpretations of whether timezone is standard or not. Bit of a strawman, granted. Maybe working at Microsoft has made me overly cautious about changes that could break *anyone* - it's a big deal in many groups here. |
|
|
msg246821 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2015-07-16 20:29 |
For me, it's not the responsability of python.h to ensure that the timezone symbol is available. |
|
|
msg246823 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2015-07-16 20:38 |
Agreed. However, I also don't want extensions to stop building because of a change we make. But since that's inevitable here, let's go with Zach's original suggestion and use a name that won't conflict. (IIRC, I originally put the #ifdefs in each file and was told to move them to pyconfig.h...) |
|
|
msg246826 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2015-07-16 20:50 |
> (IIRC, I originally put the #ifdefs in each file and was told to move > them to pyconfig.h...) Yeah, I think I did suggest that, to match what we do with hypot/_hypot for MSC 1600+. We should probably also change that one while fixing timezone, daylight, and tzname. |
|
|
msg325250 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2018-09-13 14:43 |
This was just reported again in bpo-34657. We should go ahead and define _Py_timezone et al., which I will try to do today if nobody beats me to it :) |
|
|
msg325254 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2018-09-13 15:14 |
I'd still rather put the redefinitions in our files that need it, and leave end users untouched. |
|
|
msg336473 - (view) |
Author: Zackery Spytz (ZackerySpytz) *  |
Date: 2019-02-24 15:01 |
I've created a PR for this issue. |
|
|
msg336583 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2019-02-25 23:56 |
New changeset 6673decfa0fb078f60587f5cb5e98460eea137c2 by Steve Dower (Zackery Spytz) in branch 'master': bpo-24643: Fix "#define timezone _timezone" clashes on Windows (GH-12019) https://github.com/python/cpython/commit/6673decfa0fb078f60587f5cb5e98460eea137c2 |
|
|
msg336586 - (view) |
Author: miss-islington (miss-islington) |
Date: 2019-02-26 00:15 |
New changeset 0b3019a02e60171e9b7edb261e1234109001819c by Miss Islington (bot) in branch '3.7': bpo-24643: Fix "GH-define timezone _timezone" clashes on Windows (GH-12019) https://github.com/python/cpython/commit/0b3019a02e60171e9b7edb261e1234109001819c |
|
|
msg336696 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2019-02-26 16:54 |
Thanks, Zackery! |
|
|