[New-bugs-announce] [issue32457] Windows Python cannot handle an early PATH entry containing ".." and python.exe

Ray Donnelly report at bugs.python.org
Sat Dec 30 13:58:32 EST 2017

New submission from Ray Donnelly <rdonnelly at anaconda.com>:

Over on the Anaconda Distribution we received a (private) bug report about a crash when trying to use scons. I thought initially it was due to one of our patches but I tested it out with official CPython and also with WinPython and ran into the same crash.

To reproduce this, from cmd.exe on CPython (here I installed CPython as part of Visual Studio 2017, then updated it to the latest 3.6.4 release):

set "PATH=C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts\..;%PATH%"



Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000328 (most recent call first):

The trigger for this bug is the following batch code in scons.bat:


My current thinking is that the best fix here is to modify get_progpath()/get_program_full_path() so that it uses PathCchCanonicalizeEx() at https://github.com/python/cpython/blob/9bee329130aae5a13050c08dab9d349b76e66835/PC/getpathp.c#L558-L559

components: Windows
messages: 309242
nosy: Ray Donnelly, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Windows Python cannot handle an early PATH entry containing ".." and python.exe
type: crash
versions: Python 3.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list