cpython: 16a386443055 (original) (raw)
Mercurial > cpython
changeset 68684:16a386443055
merge from upstream
Skip Montanaro skip@pobox.com | |
---|---|
date | Sat, 19 Mar 2011 13:03:33 -0500 |
parents | 64eeb4cd4b56(current diff)cb148da52c47(diff) |
children | 145c3703ce48 |
files | |
diffstat | 6 files changed, 24 insertions(+), 5 deletions(-)[+] [-] Doc/library/platform.rst 2 Lib/os.py 4 Lib/platform.py 2 Lib/subprocess.py 2 Lib/test/test_subprocess.py 16 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Doc/library/platform.rst
+++ b/Doc/library/platform.rst
@@ -208,7 +208,7 @@ Windows Platform
Win95/98 specific
^^^^^^^^^^^^^^^^^
-.. function:: popen(cmd, mode='r', bufsize=None)
+.. function:: popen(cmd, mode='r', bufsize=-1)
Portable :func:popen
interface. Find a working popen implementation
preferring :func:win32pipe.popen
. On Windows NT, :func:win32pipe.popen
--- a/Lib/os.py +++ b/Lib/os.py @@ -779,11 +779,13 @@ if not _exists("urandom"): return bs
Supply os.popen()
-def popen(cmd, mode="r", buffering=None): +def popen(cmd, mode="r", buffering=-1): if not isinstance(cmd, str): raise TypeError("invalid cmd type (%s, expected string)" % type(cmd)) if mode not in ("r", "w"): raise ValueError("invalid mode %r" % mode)
- if buffering == 0 or buffering == None:
import subprocess, io if mode == "r": proc = subprocess.Popen(cmd,raise ValueError("popen() does not support unbuffered streams")[](#l2.14)
--- a/Lib/platform.py +++ b/Lib/platform.py @@ -357,7 +357,7 @@ def dist(distname='',version='',id='', supported_dists=supported_dists, full_distribution_name=0) -def popen(cmd, mode='r', bufsize=None): +def popen(cmd, mode='r', bufsize=-1): """ Portable popen() interface. """
--- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -743,8 +743,6 @@ class Popen(object): if errread != -1: errread = msvcrt.open_osfhandle(errread.Detach(), 0)
if bufsize == 0:[](#l4.7)
bufsize = 1 # Nearly unbuffered (XXX for now)[](#l4.8) if p2cwrite != -1:[](#l4.9) self.stdin = io.open(p2cwrite, 'wb', bufsize)[](#l4.10) if self.universal_newlines:[](#l4.11)
--- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1315,6 +1315,22 @@ class POSIXProcessTestCase(BaseTestCase) " non-zero with this error:\n%s" % stderr.decode('utf-8'))
- def test_select_unbuffered(self):
# Issue #11459: bufsize=0 should really set the pipes as[](#l5.8)
# unbuffered (and therefore let select() work properly).[](#l5.9)
select = support.import_module("select")[](#l5.10)
p = subprocess.Popen([sys.executable, "-c",[](#l5.11)
'import sys;'[](#l5.12)
'sys.stdout.write("apple")'],[](#l5.13)
stdout=subprocess.PIPE,[](#l5.14)
bufsize=0)[](#l5.15)
f = p.stdout[](#l5.16)
try:[](#l5.17)
self.assertEqual(f.read(4), b"appl")[](#l5.18)
self.assertIn(f, select.select([f], [], [], 0.0)[0])[](#l5.19)
finally:[](#l5.20)
p.wait()[](#l5.21)
+ @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase):
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -75,6 +75,9 @@ Core and Builtins
Library
-------
+- Issue #11459: A bufsize
value of 0 in subprocess.Popen() really creates