[New-bugs-announce] [issue20596] Support for alternate wcstok syntax for Windows compilers

Jeffrey Armstrong report at bugs.python.org
Tue Feb 11 14:03:36 CET 2014

New submission from Jeffrey Armstrong:

In two locations, the current interpreter code makes some assumptions concerning the syntax of the wcstok() function based solely on the operating system (Windows, in this case).  Compilers other than MSVC may (and do) provide alternative wcstok() syntaxes.

The first change in the attached patch changes a preprocessor check in Modules/main.c to determine if we're compiling with MSVC rather than just whether we're compiling with Windows.  If so, it uses Windows's basic two-argument wcstok() function as it always has.  If the compiler isn't MSVC, the code will now default to the Unix method of converting to ASCII first before tokenizing.  This change is more sensible because the code should really be checking for the compiler's wcstok() capabilities, not what operating system Python is being compiled for.

The second change in the attached patch adds some new code to PC/getpathp.c to support alternate wcstok() syntax in the find_env_config_value() function.  A preprocessor check will now determine if we're compiling for MSVC and, if so, default to the three-argument wcstok_s() function.  If the almost-compatible Open Watcom compiler is detected, a three-argument, POSIX-like wcstok() function is used.  If another compiler is detected, the original two-argument wcstok() is assumed to be adequate.

components: Interpreter Core, Windows
files: wcstok.default.patch
keywords: patch
messages: 210935
nosy: Jeffrey.Armstrong
priority: normal
severity: normal
status: open
title: Support for alternate wcstok syntax for Windows compilers
type: compile error
versions: Python 3.4
Added file: http://bugs.python.org/file34038/wcstok.default.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list