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

Created on 2008-08-31 17:14 by TBBle, last changed 2008-11-28 11:05 by christian.heimes. This issue is now closed.

Files
File name Uploaded Description Edit
msvc9compiler-windowssdk.diff TBBle, 2008-08-31 17:14 Patch to fix msvc9compiler.py 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), msvc9compiler.py 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
msvccompiler.py was duplicated into msvc9compiler.py in revision 59290.

http://svn.python.org/view?rev=59290&view=rev
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/msvc9compiler.py
--- a/Lib/distutils/msvc9compiler.py    Thu Oct 09 11:19:40 2008 +0200
+++ b/Lib/distutils/msvc9compiler.py    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).
History
Date User Action Args
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