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.

Title: DISTUTILS_USE_SDK set causes to raise an exception
Type: compile error Stage: patch review
Components: Distutils, Windows Versions: Python 3.0, Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: TBBle, barry, benjamin.peterson, broche, cboos, christian.heimes
Priority: release blocker Keywords: patch

Created on 2008-08-31 17:14 by TBBle, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
msvc9compiler-windowssdk.diff TBBle, 2008-08-31 17:14 Patch to fix in the simplest way possible
Messages (6)
msg72209 - (view) Author: Paul "TBBle" Hampson (TBBle) Date: 2008-08-31 17:14
Basically, if DISTUTILS_USE_SDK is set in the environment and an
extension is attempted to be built from within the Windows SDK shell
(ie. MSSdk is set in the environment as well), will
raise an exception due to a reference to the undefined self.__paths in
MSVCCompiler.find_exe class, called from MSVCCompiler.initialize.

self.__paths is used both in MSVCCompiler.find_exe and further through
MSVCCompiler.initialize, but only exists if the else branch of the
DISTUTILS_USE_SDK if/else is taken.

I've attached a patch which trivially fixes this by setting self.__paths
to [] before the test for DISTUTILS_USE_SDK.

However, the use of MSVCCompiler.find_exe in this test might be wrong.
Short of raising an exception, MSVCCompiler.find_exe always returns what
it is supplied if it can't find anything better. So testing the truth of
this value is likely incorrect. (I assume that find_exe used to return a
false value if the requested program could not be found on the path or
in self.__paths[]...)

If the find_exe is removed from the test, then the setting of
self.__paths can be done inside the if branch, paralleling the else branch.
msg72210 - (view) Author: Paul "TBBle" Hampson (TBBle) Date: 2008-08-31 17:25
The line my patch adds was present originally, and lost when was duplicated into in revision 59290.
msg74563 - (view) Author: Christian Boos (cboos) * Date: 2008-10-09 10:06
Hit the same issue, which is actually only a typo, as self.__path is 
used nowhere.

diff -r 4d10dcbd5f63 Lib/distutils/
--- a/Lib/distutils/    Thu Oct 09 11:19:40 2008 +0200
+++ b/Lib/distutils/    Thu Oct 09 12:01:27 2008 +0200
@@ -316,7 +316,7 @@
         self.__version = VERSION
         self.__root = r"Software\Microsoft\VisualStudio"
         # self.__macros = MACROS
-        self.__path = []
+        self.__paths = []
         # target platform (.plat_name is consistent with 'bdist')
         self.plat_name = None
         self.__arch = None # deprecated name
msg75654 - (view) Author: Bryon Roche (broche) Date: 2008-11-09 16:54
This patch works in the build system I'm using as well.  Can we get this
in py2.6.epsilon?
msg75656 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-11-09 17:38
I'll take it from here.
msg76524 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-11-28 11:05
Fixed in r67414, r67415, r67416 (trunk, 2.6, 3.0).
Date User Action Args
2022-04-11 14:56:38adminsetnosy: + barry, benjamin.peterson
github: 47991
2008-11-28 11:05:25christian.heimessetstatus: open -> closed
resolution: fixed
messages: + msg76524
2008-11-21 15:16:48barrysetpriority: deferred blocker -> release blocker
2008-11-09 17:38:04christian.heimessetpriority: deferred blocker
assignee: christian.heimes
type: behavior -> compile error
components: + Windows
versions: + Python 3.0, Python 2.7
nosy: + christian.heimes
messages: + msg75656
stage: patch review
2008-11-09 16:54:52brochesettype: behavior
messages: + msg75654
nosy: + broche
2008-10-09 10:06:10cboossetnosy: + cboos
messages: + msg74563
2008-08-31 17:25:34TBBlesetmessages: + msg72210
2008-08-31 17:14:48TBBlecreate