[New-bugs-announce] [issue34657] pyconfig.h macro "timezone" name clashes with user source are likely

Mark Mikofski report at bugs.python.org
Thu Sep 13 02:10:52 EDT 2018


New submission from Mark Mikofski <bwana.marko at yahoo.com>:

TL;DR: if PC user compiles source which defines "timezone" in a header, and includes Python.h after the header, then the macro also called "timezone" in pyconfig.h will redefine the users source, yielding unexpected results.

see Cython google group for an actual use case where this occurred:
https://groups.google.com/forum/#!topic/cython-users/pjbhYrpl_rU

trying to compile NREL SPA code which has a header file with a struct with a timezone field fails with the following traceback:
spa.h(88): error C2032: '__timezone': function cannot be member of struct '<anonymous-tag>'

here's the macro in PC/pyconfig.h in master as of 5489bdad
https://github.com/python/cpython/blob/5489bdad5143050b8bb89b648b3c00d951b72d4f/PC/pyconfig.h#L202

/* VS 2015 defines these names with a leading underscore */
#if _MSC_VER >= 1900
#define timezone _timezone
#define daylight _daylight
#define tzname _tzname
#endif

----------
components: Build
messages: 325235
nosy: bwanamarko
priority: normal
severity: normal
status: open
title: pyconfig.h macro "timezone" name clashes with user source are likely
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34657>
_______________________________________


More information about the New-bugs-announce mailing list