summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2011-03-27 17:34:22 +0200
committerRoss Lagerwall <rosslagerwall@gmail.com>2011-03-27 17:34:22 +0200
commitf382ab25caeca70fe6814821160651511c0f420d (patch)
treeed84189558e28fb4bae9e99abf810079c546027c
parent756ebc79cf5d8b904b2cda21b003d76aa48f6f28 (diff)
downloadcpython-git-f382ab25caeca70fe6814821160651511c0f420d.tar.gz
Issue #11692: Remove unnecessary demo functions in subprocess module.
-rw-r--r--Lib/subprocess.py65
-rw-r--r--Misc/NEWS2
2 files changed, 2 insertions, 65 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 4c6635352f..40f9636ff9 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1723,68 +1723,3 @@ class Popen(object):
"""Kill the process with SIGKILL
"""
self.send_signal(signal.SIGKILL)
-
-
-def _demo_posix():
- #
- # Example 1: Simple redirection: Get process list
- #
- plist = Popen(["ps"], stdout=PIPE).communicate()[0]
- print("Process list:")
- print(plist)
-
- #
- # Example 2: Change uid before executing child
- #
- if os.getuid() == 0:
- p = Popen(["id"], preexec_fn=lambda: os.setuid(100))
- p.wait()
-
- #
- # Example 3: Connecting several subprocesses
- #
- print("Looking for 'hda'...")
- p1 = Popen(["dmesg"], stdout=PIPE)
- p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
- print(repr(p2.communicate()[0]))
-
- #
- # Example 4: Catch execution error
- #
- print()
- print("Trying a weird file...")
- try:
- print(Popen(["/this/path/does/not/exist"]).communicate())
- except OSError as e:
- if e.errno == errno.ENOENT:
- print("The file didn't exist. I thought so...")
- print("Child traceback:")
- print(e.child_traceback)
- else:
- print("Error", e.errno)
- else:
- print("Gosh. No error.", file=sys.stderr)
-
-
-def _demo_windows():
- #
- # Example 1: Connecting several subprocesses
- #
- print("Looking for 'PROMPT' in set output...")
- p1 = Popen("set", stdout=PIPE, shell=True)
- p2 = Popen('find "PROMPT"', stdin=p1.stdout, stdout=PIPE)
- print(repr(p2.communicate()[0]))
-
- #
- # Example 2: Simple execution of program
- #
- print("Executing calc...")
- p = Popen("calc")
- p.wait()
-
-
-if __name__ == "__main__":
- if mswindows:
- _demo_windows()
- else:
- _demo_posix()
diff --git a/Misc/NEWS b/Misc/NEWS
index e7446f3f48..016d07eba1 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -87,6 +87,8 @@ Core and Builtins
Library
-------
+- Issue #11692: Remove unnecessary demo functions in subprocess module.
+
- Issue #11675: multiprocessing.[Raw]Array objects created from an integer size
are now zeroed on creation. This matches the behaviour specified by the
documentation.