[Python-checkins] r68081 - in python/trunk: Lib/distutils/msvc9compiler.py Lib/distutils/tests/test_msvc9compiler.py Misc/NEWS

tarek.ziade python-checkins at python.org
Wed Dec 31 00:03:48 CET 2008


Author: tarek.ziade
Date: Wed Dec 31 00:03:41 2008
New Revision: 68081
Log:
Fixed #4702: Throwing DistutilsPlatformError instead of IOError under win32 if MSVC is not found
Added:
 python/trunk/Lib/distutils/tests/test_msvc9compiler.py (contents, props changed)
Modified:
 python/trunk/Lib/distutils/msvc9compiler.py
 python/trunk/Misc/NEWS
Modified: python/trunk/Lib/distutils/msvc9compiler.py
==============================================================================
--- python/trunk/Lib/distutils/msvc9compiler.py	(original)
+++ python/trunk/Lib/distutils/msvc9compiler.py	Wed Dec 31 00:03:41 2008
@@ -247,7 +247,7 @@
 result = {}
 
 if vcvarsall is None:
- raise IOError("Unable to find vcvarsall.bat")
+ raise DistutilsPlatformError("Unable to find vcvarsall.bat")
 log.debug("Calling 'vcvarsall.bat %s' (version=%s)", arch, version)
 popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch),
 stdout=subprocess.PIPE,
@@ -255,7 +255,7 @@
 
 stdout, stderr = popen.communicate()
 if popen.wait() != 0:
- raise IOError(stderr.decode("mbcs"))
+ raise DistutilsPlatformError(stderr.decode("mbcs"))
 
 stdout = stdout.decode("mbcs")
 for line in stdout.split("\n"):
Added: python/trunk/Lib/distutils/tests/test_msvc9compiler.py
==============================================================================
--- (empty file)
+++ python/trunk/Lib/distutils/tests/test_msvc9compiler.py	Wed Dec 31 00:03:41 2008
@@ -0,0 +1,33 @@
+"""Tests for distutils.msvc9compiler."""
+import sys
+import unittest
+
+from distutils.errors import DistutilsPlatformError
+
+class msvc9compilerTestCase(unittest.TestCase):
+
+ def test_no_compiler(self):
+ # makes sure query_vcvarsall throws
+ # a DistutilsPlatformError if the compiler
+ # is not found
+ if sys.platform != 'win32':
+ # this test is only for win32
+ return
+ from distutils.msvc9compiler import query_vcvarsall
+ def _find_vcvarsall(version):
+ return None
+
+ from distutils import msvc9compiler
+ old_find_vcvarsall = msvc9compiler.find_vcvarsall
+ msvc9compiler.find_vcvarsall = _find_vcvarsall
+ try:
+ self.assertRaises(DistutilsPlatformError, query_vcvarsall,
+ 'wont find this version')
+ finally:
+ msvc9compiler.find_vcvarsall = old_find_vcvarsall
+
+def test_suite():
+ return unittest.makeSuite(msvc9compilerTestCase)
+
+if __name__ == "__main__":
+ unittest.main(defaultTest="test_suite")
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Dec 31 00:03:41 2008
@@ -100,6 +100,9 @@
 Library
 -------
 
+- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case 
+ no MSVC compiler is found under Windows. Original patch by Philip Jenvey. 
+
 - Issue #4646: distutils was choking on empty options arg in the setup 
 function. Original patch by Thomas Heller.
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /