[New-bugs-announce] [issue23876] Fix mkdir() call for Watcom compilers on UNIX-like platforms

Jeffrey Armstrong report at bugs.python.org
Mon Apr 6 14:41:15 CEST 2015


New submission from Jeffrey Armstrong:

Within Modules/posixmodule.c:4914 (in 3.5.0a3), the preprocessor checks for compiler macros as such:

#if ( defined(__WATCOMC__) || defined(PYCC_VACPP) ) && !defined(__QNX__)
        result = mkdir(path->narrow);
#else
        result = mkdir(path->narrow, mode);
#endif

The purpose of the code was to detect if we're compiling using Watcom, but not on QNX, or VisualAge as our compiler, where mkdir() wouldn't accept a mode.  However, Watcom supports Linux as well and properly implements the mode argument, causing the compilation to fail.

The proper check, rather than looking for "!defined(__QNX__)" would be "!defined(__UNIX__)," which would allow the code to properly compile using Watcom on either Linux or QNX:

#if ( defined(__WATCOMC__) || defined(PYCC_VACPP) ) && !defined(__UNIX__)
        result = mkdir(path->narrow);
#else
        result = mkdir(path->narrow, mode);
#endif


FYI, in Watcom, the __UNIX__ macro is defined on both Linux and QNX, so this change will not break code for people who are still using Watcom to build Python for QNX (which is probably nobody at all).

There are two other places where the __QNX__ macro should be replaced in Modules/posixmodule.c, and the attached patch fixes both.

----------
components: Interpreter Core
files: watcom_qnx_to_unix-3.5.0a3.patch
keywords: patch
messages: 240153
nosy: Jeffrey.Armstrong
priority: normal
severity: normal
status: open
title: Fix mkdir() call for Watcom compilers on UNIX-like platforms
type: compile error
versions: Python 3.5
Added file: http://bugs.python.org/file38843/watcom_qnx_to_unix-3.5.0a3.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23876>
_______________________________________


More information about the New-bugs-announce mailing list