This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PATH_MAX already defined on some Windows compilers
Type: compile error Stage:
Components: Interpreter Core, Windows Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Jeffrey.Armstrong, larry, loewis, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2014-02-11 13:11 by Jeffrey.Armstrong, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
path_max.default.patch Jeffrey.Armstrong, 2014-02-11 13:11 Patch to check for PATH_MAX definition before defining it on Windows
remove_path_max.default.patch Jeffrey.Armstrong, 2014-02-11 16:51 Removes PATH_MAX defines entirely review
Messages (15)
msg210936 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-02-11 13:11
On some Windows compilers, the constant PATH_MAX may already be defined, which will cause compile errors on non-MSVC compilers (notably Open Watcom and MinGW).  Rather than assume it is not available and define it in all "#ifdef MS_WINDOWS" cases, it should first be checked for existence.

This patch adds said check to Modules/main.c and Python/pythonrun.c.  This patch should not affect any existing platforms (including MSVC builds).
msg210962 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-02-11 16:27
The patch is simple and looks safe. I'm in favor of applying it on Python 3.3 and 3.4. (Python 2.7 is not affect.)

@Larry: ok for Python 3.4?
msg210966 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-02-11 16:38
Let's be a little smarter.  PATH_MAX isn't used anymore.  Just remove the #defines entirely.
msg210971 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-02-11 16:51
Here's an additional patch removing PATH_MAX from Modules/main.c and Python/pythonrun.c.  This solution works fine for me.
msg210985 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-02-11 17:37
> Let's be a little smarter.  PATH_MAX isn't used anymore.  Just remove the #defines entirely.

Oh I remember that I replaced PATH_MAX with MAXPATHLEN or maybe something else when I tried to fix Python compilation issue on our IRIX buildbot :-)

remove_path_max.default.patch looks good to me. Larry: can it be applied on Python 3.4?

path_max.default.patch is still needed for Python 3.3.
msg210986 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-02-11 17:38
I found it:

changeset:   87113:159e51e5fc2c
branch:      3.3
parent:      87102:46fc4fb2c8c5
user:        Victor Stinner <victor.stinner@gmail.com>
date:        Fri Nov 15 17:09:24 2013 +0100
files:       Python/pythonrun.c
description:
pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get the size of
the env_home buffer, not PATH_MAX+1. env_home is declared using MAXPATHLEN+1,
and PATH_MAX is not declared on IRIX.
msg210997 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-02-11 18:40
Jeffrey: Which compilers specifically?

It's probably not MSVC, hence it's not a "supported" compiler, and IMO shouldn't go in after the release candidate for 3.4.
msg211000 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-02-11 19:03
PATH_MAX is defined in both Open Watcom and MinGW's GCC toolchain.  Neither is a "supported" compiler, I suppose.  I hadn't meant to suggest that it be included in 3.4's release candidate, only that the problem exists on current versions.
msg211004 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-02-11 19:26
Assuming you keep an eye on the buildbots, this has my permission to go in.

Martin: While we don't officially support those compilers, I don't see the harm of removing unused #defines, so I'm willing to accept it for rc2.
msg226598 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-09-08 19:00
Was this ever accepted?
msg230662 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-11-05 07:05
Reopening. I still don't understand the issue for 3.4, especially in the light of #21274
msg230673 - (view) Author: Jeffrey Armstrong (Jeffrey.Armstrong) * Date: 2014-11-05 11:27
What's to understand?  Some compilers, particularly MinGW and Open Watcom, already define a PATH_MAX macro on Windows, and it's not necessarily the same as Python's redefinition of it, possibly causing a compiler error.  That's all.

Given the time frame that this bug has existed (9 months!?!) and its trivial fix, which would involve adding an  "#ifndef PATH_MAX" right before its declaration, I think "won't fix" is an appropriate resolution.

Leave it open or don't, it makes little difference to me as I'm no longer interested.
msg230679 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-05 14:12
New changeset 6aaa0aab1e93 by Victor Stinner in branch 'default':
Issue #20597: Remove unused definition of PATH_MAX on Windows, MAXPATHLEN is
https://hg.python.org/cpython/rev/6aaa0aab1e93
msg230681 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-05 14:15
New changeset d6fb87972dee by Victor Stinner in branch 'default':
Issue #20597, #21274: Remove unused definition of PATH_MAX on GNU/Hurd,
https://hg.python.org/cpython/rev/d6fb87972dee
msg230682 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-11-05 14:18
> Reopening. I still don't understand the issue for 3.4, especially in the light of #21274

In Python 3.5, PATH_MAX is no more used in Modules/main.c nor Python/pythonrun.c. I removed the "#define PATH_MAX ..." on Windows on Hurd.

This issue is about supporting OpenWatcom which is not officially supported to compile Python on Windows, so I don't want to change Python 2.7 nor 3.4. If anyone disagree, please complain :-)

PATH_MAX is still used in posixmodule.c, but it looks to work on all platforms:

#ifndef MAXPATHLEN
#if defined(PATH_MAX) && PATH_MAX > 1024
#define MAXPATHLEN PATH_MAX
#else
#define MAXPATHLEN 1024
#endif
#endif /* MAXPATHLEN */

I'm now closing this issue.
History
Date User Action Args
2022-04-11 14:57:58adminsetgithub: 64796
2014-11-05 14:18:35vstinnersetstatus: open -> closed
resolution: wont fix -> fixed
messages: + msg230682
2014-11-05 14:15:40python-devsetmessages: + msg230681
2014-11-05 14:12:18python-devsetnosy: + python-dev
messages: + msg230679
2014-11-05 11:27:00Jeffrey.Armstrongsetmessages: + msg230673
2014-11-05 07:05:16loewissetstatus: closed -> open

messages: + msg230662
2014-11-04 21:20:48Jeffrey.Armstrongsetstatus: open -> closed
resolution: wont fix
2014-09-08 19:00:44Jeffrey.Armstrongsetmessages: + msg226598
2014-02-11 19:26:49larrysetmessages: + msg211004
2014-02-11 19:03:25Jeffrey.Armstrongsetmessages: + msg211000
2014-02-11 18:40:31loewissetmessages: + msg210997
2014-02-11 17:38:43vstinnersetmessages: + msg210986
2014-02-11 17:37:49vstinnersetmessages: + msg210985
2014-02-11 16:51:53Jeffrey.Armstrongsetfiles: + remove_path_max.default.patch

messages: + msg210971
2014-02-11 16:38:30larrysetmessages: + msg210966
2014-02-11 16:27:11vstinnersetnosy: + loewis, vstinner, serhiy.storchaka, larry
messages: + msg210962
2014-02-11 13:11:15Jeffrey.Armstrongcreate