Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ace5586

Browse files
committed
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!
1 parent 3c28878 commit ace5586

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

Lib/subprocess.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,10 @@ class STARTUPINFO:
433433

434434

435435
__all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput",
436-
"getoutput", "check_output", "CalledProcessError", "DEVNULL"]
436+
"getoutput", "check_output", "CalledProcessError", "DEVNULL",
437+
"SubprocessError", "TimeoutExpired"]
438+
# NOTE: We intentionally exclude list2cmdline as it is
439+
# considered an internal implementation detail. issue10838.
437440

438441
if mswindows:
439442
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,

Lib/test/test_subprocess.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,6 +2420,21 @@ def tearDown(self):
24202420
subprocess._PopenSelector = self.orig_selector
24212421
ProcessTestCase.tearDown(self)
24222422

2423+
def test__all__(self):
2424+
"""Ensure that __all__ is populated properly."""
2425+
intentionally_excluded = set(("list2cmdline", "mswindows", "MAXFD"))
2426+
exported = set(subprocess.__all__)
2427+
possible_exports = set()
2428+
import types
2429+
for name, value in subprocess.__dict__.items():
2430+
if name.startswith('_'):
2431+
continue
2432+
if isinstance(value, (types.ModuleType,)):
2433+
continue
2434+
possible_exports.add(name)
2435+
self.assertEqual(exported, possible_exports - intentionally_excluded)
2436+
2437+
24232438

24242439
@unittest.skipUnless(mswindows, "Windows-specific tests")
24252440
class CommandsWithSpaces (BaseTestCase):

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Core and Builtins
1919
Library
2020
-------
2121

22+
- Issue #10838: The subprocess now module includes SubprocessError and
23+
TimeoutError in its list of exported names for the users wild enough
24+
to use "from subprocess import *".
25+
2226
- Issue #23411: Added DefragResult, ParseResult, SplitResult, DefragResultBytes,
2327
ParseResultBytes, and SplitResultBytes to urllib.parse.__all__.
2428
Patch by Martin Panter.

0 commit comments

Comments
 (0)