[issue21482] get_versions() in cygwinccomiler.py cannot return correct gcc version

Joe Chan report at bugs.python.org
Mon May 12 18:27:20 CEST 2014


Joe Chan added the comment:

better to parenthesis all three exes[gcc, ld and dllwrap] with "%s" to better support path names that contain non-alphanumeric characters.

$ diff -rupN cygwinccompiler.py.original cygwinccompiler.py
--- cygwinccompiler.py.original 2014-05-12 23:54:01.296303800 +0800
+++ cygwinccompiler.py  2014-05-13 00:24:08.754684500 +0800
@@ -418,19 +418,19 @@ def get_versions():

     gcc_exe = find_executable('gcc')
     if gcc_exe:
-        out = os.popen(gcc_exe + ' -dumpversion','r')
+        out = os.popen('"%s" -dumpversion'%gcc_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
         if result:
             gcc_version = LooseVersion(result.group(1))
         else:
-            gcc_version = None
+            gcc_version = None
     else:
         gcc_version = None
     ld_exe = find_executable('ld')
     if ld_exe:
-        out = os.popen(ld_exe + ' -v','r')
+        out = os.popen('"%s" -v'%ld_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
@@ -442,7 +442,7 @@ def get_versions():
         ld_version = None
     dllwrap_exe = find_executable('dllwrap')
     if dllwrap_exe:
-        out = os.popen(dllwrap_exe + ' --version','r')
+        out = os.popen('"%s" --version'%dllwrap_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search(' (\d+\.\d+(\.\d+)*)',out_string)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21482>
_______________________________________


More information about the Python-bugs-list mailing list