summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2010-12-04 09:10:44 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2010-12-04 09:10:44 (GMT)
commitd23047b62c6f885def9020bd9b304110f9b9c52d (patch)
tree4adeb352a619ce0ce869f93ea792d6ab8403ee64 /Lib/subprocess.py
parent35f08f0f844186f3a3f3a4dd477ea22d589886de (diff)
downloadcpython-d23047b62c6f885def9020bd9b304110f9b9c52d.zip
cpython-d23047b62c6f885def9020bd9b304110f9b9c52d.tar.gz
cpython-d23047b62c6f885def9020bd9b304110f9b9c52d.tar.bz2
issue7213 + issue2320: Cause a DeprecationWarning if the close_fds argument is
not passed to subprocess.Popen as the default value will be changing in a future Python to the safer and more often desired value of True. DeprecationWarnings that show up in a lot of existing code are controversial and have caused pain in the past. I'd like to leave this on for 3.2 beta1 and see how things go. We can remove the warning if it is deemed too noisy during any betas. (case study: the md5 and sha module DeprecationWarnings are loathed around the world as those modules were never going to be removed in 2.x and 2to3 has a fixer for code that uses them)
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index bdbcc6b..ca67012 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -339,6 +339,7 @@ import traceback
import gc
import signal
import builtins
+import warnings
# Exception classes used by this module.
class CalledProcessError(Exception):
@@ -378,7 +379,6 @@ else:
import _posixsubprocess
except ImportError:
_posixsubprocess = None
- import warnings
warnings.warn("The _posixsubprocess module is not being used. "
"Child process reliability may suffer if your "
"program uses threads.", RuntimeWarning)
@@ -605,7 +605,7 @@ def getoutput(cmd):
class Popen(object):
def __init__(self, args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
+ preexec_fn=None, close_fds=None, shell=False,
cwd=None, env=None, universal_newlines=False,
startupinfo=None, creationflags=0,
restore_signals=True, start_new_session=False):
@@ -618,6 +618,15 @@ class Popen(object):
if not isinstance(bufsize, int):
raise TypeError("bufsize must be an integer")
+ if close_fds is None:
+ # Notification for http://bugs.python.org/issue7213 & issue2320
+ warnings.warn(
+ 'The close_fds parameter was not specified. Its default'
+ ' will change from False to True in a future Python'
+ ' version. Most users should set it to True. Please'
+ ' update your code explicitly set close_fds.',
+ DeprecationWarning)
+
if mswindows:
if preexec_fn is not None:
raise ValueError("preexec_fn is not supported on Windows "