[issue10752] build_ssl.py is relying on unreliable behaviour of os.popen

Gabi Davar report at bugs.python.org
Mon Mar 25 21:52:53 CET 2013


Gabi Davar added the comment:

possibly better patch - uses subprocess' quoting logic for argument handling:
diff -r 6fc9103d55f0 PCbuild/build_ssl.py
--- a/PCbuild/build_ssl.py	Sun Mar 24 14:54:25 2013 -0700
+++ b/PCbuild/build_ssl.py	Mon Mar 25 17:28:19 2013 +0200
@@ -47,10 +47,10 @@
 # is available.
 def find_working_perl(perls):
     for perl in perls:
-        fh = os.popen('"%s" -e "use Win32;"' % perl)
-        fh.read()
-        rc = fh.close()
-        if rc:
+        import subprocess
+        try:
+            subprocess.check_call([perl, '-e', 'use Win32;'], shell=True)
+        except subprocess.CalledProcessError:
             continue
         return perl
     print("Can not find a suitable PERL:")

----------
nosy: +Gabi.Davar

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


More information about the Python-bugs-list mailing list