Package: python3.2 Version: 3.2.2-4 Severity: important Dear Maintainer,
In newer versions of Python, it appears pipes cannot be passed from one subprocess to another via subprocess.Popen calls; they are still closed even though the close_fds arg is specified as False. I am appending a test script to illustrate the problem. Try running this with different versions of Python, and observe the difference: it works fine with 2.6 and 3.1, and fails with 2.7 and 3.2. -- System Information: Debian Release: wheezy/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'oldstable'), (101, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_NZ.UTF-8, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_NZ.utf8) Shell: /bin/sh linked to /bin/bash Versions of packages python3.2 depends on: ii libbz2-1.0 1.0.6-1 ii libc6 2.13-24 ii libdb5.1 5.1.29-1 ii libgcc1 1:4.6.2-12 ii libncursesw5 5.9-4 ii libreadline6 6.2-8 ii libsqlite3-0 3.7.9-3 ii libtinfo5 5.9-4 ii mime-support 3.51-1 ii python3.2-minimal 3.2.2-4 python3.2 recommends no packages. Versions of packages python3.2 suggests: pn binutils 2.22-5 pn python3.2-doc <none> -- no debconf information
#+ # Demonstration of misbehaviour of close_fds arg to subprocess.Popen # on certain versions of Python. This process creates two subprocesses, # specifying that stdin of the first one is connected to a pipe. That # pipe should be passed to the second process, but in some cases it's not. # # Try this script with various versions of Python, for example # # python2.6 test.py # python2.7 test.py # python3.1 test.py # python3.2 test.py # # and note the differences in the output. Details on what to look for are # below. # # Written 2012 February 1 by Lawrence D'Oliveiro <l...@geek-central.gen.nz>. #- import subprocess child1 = subprocess.Popen \ ( args = ["bash", "-c", "sleep 5"], shell = True, stdin = subprocess.PIPE, close_fds = True, ) child2 = subprocess.Popen \ ( args = [ "ls", "-l", "/dev/fd/", ], close_fds = False, shell = False, ) # Example of correct output (e.g. Python versions 2.6 and 3.1): # total 0 # lrwx------ 1 ldo users 64 Feb 1 09:00 0 -> /dev/pts/2 # lrwx------ 1 ldo users 64 Feb 1 09:00 1 -> /dev/pts/2 # lrwx------ 1 ldo users 64 Feb 1 09:00 2 -> /dev/pts/2 # lr-x------ 1 ldo users 64 Feb 1 09:00 3 -> /proc/2833/fd # l-wx------ 1 ldo users 64 Feb 1 09:00 4 -> pipe:[714773] # # Example of incorrect output (e.g. Python versions 2.7 and 3.2): # total 0 # lrwx------ 1 ldo users 64 Feb 1 09:03 0 -> /dev/pts/2 # lrwx------ 1 ldo users 64 Feb 1 09:03 1 -> /dev/pts/2 # lrwx------ 1 ldo users 64 Feb 1 09:03 2 -> /dev/pts/2 # lr-x------ 1 ldo users 64 Feb 1 09:03 3 -> /proc/3156/fd # # Note the pipe file descriptor is missing in the second case.