]> granicus.if.org Git - python/commitdiff
Raise TypeError if bufsize argument is not an integer. Patch 1071755, slightly modified.
authorPeter Astrand <astrand@lysator.liu.se>
Tue, 30 Nov 2004 21:04:45 +0000 (21:04 +0000)
committerPeter Astrand <astrand@lysator.liu.se>
Tue, 30 Nov 2004 21:04:45 +0000 (21:04 +0000)
Lib/subprocess.py
Lib/test/test_subprocess.py

index 8d0204e25d8ec1d8abbe48805d7b434df4e9684b..9e326fbea42c2e940a349b04eab0cc49feefc5d2 100644 (file)
@@ -504,6 +504,9 @@ class Popen(object):
         """Create new Popen instance."""
         _cleanup()
 
+        if not isinstance(bufsize, (int, long)):
+            raise TypeError("bufsize must be an integer")
+
         if mswindows:
             if preexec_fn is not None:
                 raise ValueError("preexec_fn is not supported on Windows "
index 9f7184f057fba2f63c325c5a4fd9de0f72579228..b26d40cb29d4f65da34b7d046c7d9daeeb33eaa0 100644 (file)
@@ -394,6 +394,17 @@ class ProcessTestCase(unittest.TestCase):
         # Subsequent invocations should just return the returncode
         self.assertEqual(p.wait(), 0)
 
+
+    def test_invalid_bufsize(self):
+        # an invalid type of the bufsize argument should raise
+        # TypeError.
+        try:
+            subprocess.Popen([sys.executable, "-c", "pass"], "orange")
+        except TypeError:
+            pass
+        else:
+            self.fail("Expected TypeError")
+
     #
     # POSIX tests
     #