[Python-checkins] cpython: Addresses Issue #10838: The subprocess now module includes

gregory.p.smith python-checkins at python.org
Wed Apr 8 00:58:06 CEST 2015


https://hg.python.org/cpython/rev/10b0a8076be8
changeset:   95480:10b0a8076be8
user:        Gregory P. Smith <greg at krypto.org>
date:        Tue Apr 07 15:57:54 2015 -0700
summary:
  Addresses 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 *".

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

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

files:
  Lib/subprocess.py           |   5 ++++-
  Lib/test/test_subprocess.py |  15 +++++++++++++++
  Misc/NEWS                   |   4 ++++
  3 files changed, 23 insertions(+), 1 deletions(-)


diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -433,7 +433,10 @@
 
 
 __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,
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -2420,6 +2420,21 @@
         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):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,10 @@
 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.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list