summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2008-12-30 23:03:41 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2008-12-30 23:03:41 (GMT)
commitb1a85413b13f38a837cd753421eb4fcb23133940 (patch)
tree0a6421272bafe5e1ef686c5b8b2235af7e323429 /Lib/distutils
parent3bcb0ce922e776a92ae69882abfac65f76a67be0 (diff)
downloadcpython-b1a85413b13f38a837cd753421eb4fcb23133940.zip
cpython-b1a85413b13f38a837cd753421eb4fcb23133940.tar.gz
cpython-b1a85413b13f38a837cd753421eb4fcb23133940.tar.bz2
Fixed #4702: Throwing DistutilsPlatformError instead of IOError under win32 if MSVC is not found
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/msvc9compiler.py4
-rw-r--r--Lib/distutils/tests/test_msvc9compiler.py33
2 files changed, 35 insertions, 2 deletions
diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py
index 4f72e78..68b7775 100644
--- a/Lib/distutils/msvc9compiler.py
+++ b/Lib/distutils/msvc9compiler.py
@@ -247,7 +247,7 @@ def query_vcvarsall(version, arch="x86"):
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 @@ def query_vcvarsall(version, arch="x86"):
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"):
diff --git a/Lib/distutils/tests/test_msvc9compiler.py b/Lib/distutils/tests/test_msvc9compiler.py
new file mode 100644
index 0000000..1659cea
--- /dev/null
+++ b/Lib/distutils/tests/test_msvc9compiler.py
@@ -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")