]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Addresses Issue #10838: The subprocess now module includes
authorGregory P. Smith <greg@krypto.org>
Tue, 7 Apr 2015 22:57:54 +0000 (15:57 -0700)
committerGregory P. Smith <greg@krypto.org>
Tue, 7 Apr 2015 22:57:54 +0000 (15:57 -0700)
SubprocessError and TimeoutError in its list of exported names for the
users wild enough to use "from subprocess import *".

MAXFD, mswindows and list2cmdline should be dealt with (renamed or
moved) in separate commits.

Committed at 35,000ft.  Thanks chromebook free gogo wifi passes!

Lib/subprocess.py
Lib/test/test_subprocess.py
Misc/NEWS

index 6d2c4f5587de860a7b8ebc00b2f002f99e85b2c3..1c7eb9e552ff5794751a0c1b85acb0112b062233 100644 (file)
@@ -433,7 +433,10 @@ else:
 
 
 __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput",
-           "getoutput", "check_output", "CalledProcessError", "DEVNULL"]
+           "getoutput", "check_output", "CalledProcessError", "DEVNULL",
+           "SubprocessError", "TimeoutExpired"]
+           # NOTE: We intentionally exclude list2cmdline as it is
+           # considered an internal implementation detail.  issue10838.
 
 if mswindows:
     from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
index e25cccdbad4a7d4c3edae8813c378ccda2aee155..71481bc7969ec1bf7334c81287b9ebc8060ec4c4 100644 (file)
@@ -2420,6 +2420,21 @@ class ProcessTestCaseNoPoll(ProcessTestCase):
         subprocess._PopenSelector = self.orig_selector
         ProcessTestCase.tearDown(self)
 
+    def test__all__(self):
+        """Ensure that __all__ is populated properly."""
+        intentionally_excluded = set(("list2cmdline", "mswindows", "MAXFD"))
+        exported = set(subprocess.__all__)
+        possible_exports = set()
+        import types
+        for name, value in subprocess.__dict__.items():
+            if name.startswith('_'):
+                continue
+            if isinstance(value, (types.ModuleType,)):
+                continue
+            possible_exports.add(name)
+        self.assertEqual(exported, possible_exports - intentionally_excluded)
+
+
 
 @unittest.skipUnless(mswindows, "Windows-specific tests")
 class CommandsWithSpaces (BaseTestCase):
index 91cc87c074772cc79cd593dff527e3e15e5264c7..6c7c26364f9406471d6132b41f68070fb1c8dfe9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #10838: The subprocess now module includes SubprocessError and
+  TimeoutError in its list of exported names for the users wild enough
+  to use "from subprocess import *".
+
 - Issue #23411: Added DefragResult, ParseResult, SplitResult, DefragResultBytes,
   ParseResultBytes, and SplitResultBytes to urllib.parse.__all__.
   Patch by Martin Panter.