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

Sridhar Ratnakumar report at bugs.python.org
Wed Dec 22 00:09:42 CET 2010


New submission from Sridhar Ratnakumar <sridharr at activestate.com>:

I noticed that despite ActivePerl being installed, `os.popen(...).close()` returned 1 (see find_working_perl in build_ssl.py), while in actuality that command executed successfully with return code 0; I verified this by using the subprocess module.

Here's a patch:

--- python/PCbuild/build_ssl.py.orig
+++ python/PCbuild/build_ssl.py
@@ -45,11 +45,11 @@
 # Being a Perl dummy, the simplest way I can check is if the "Win32" package
 # is available.
 def find_working_perl(perls):
+    import subprocess
     for perl in perls:
-        fh = os.popen('"%s" -e "use Win32;"' % perl)
-        fh.read()
-        rc = fh.close()
-        if rc:
+        try:
+            subprocess.check_call('"%s" -e "use Win32;"' % perl, shell=True)
+        except subprocess.CalledProcessError:
             continue
         return perl
     print("Can not find a suitable PERL:")

----------
components: Build, Windows
messages: 124467
nosy: srid
priority: normal
severity: normal
status: open
title: build_ssl.py is relying on unreliable behaviour of os.popen
type: compile error
versions: Python 3.2

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


More information about the Python-bugs-list mailing list