From: Guido van Rossum Date: Thu, 7 Jun 2007 21:56:45 +0000 (+0000) Subject: The bufsize argument to Popen() should accept None meaning the default (0). X-Git-Tag: v3.0a1~812 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=46a05a7db5a65ebee04a43e0394672a72b37ffa1;p=python The bufsize argument to Popen() should accept None meaning the default (0). --- diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 051f2d46fb..1ae74268a2 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -465,6 +465,8 @@ class Popen(object): _cleanup() self._child_created = False + if bufsize is None: + bufsize = 0 # Restore default if not isinstance(bufsize, int): raise TypeError("bufsize must be an integer") diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index ec004bf5c5..b44e83a57b 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -455,6 +455,14 @@ class ProcessTestCase(unittest.TestCase): else: self.fail("Expected TypeError") + def test_bufsize_is_none(self): + # bufsize=None should be the same as bufsize=0. + p = subprocess.Popen([sys.executable, "-c", "pass"], None) + self.assertEqual(p.wait(), 0) + # Again with keyword arg + p = subprocess.Popen([sys.executable, "-c", "pass"], bufsize=None) + self.assertEqual(p.wait(), 0) + # # POSIX tests #