[Python-checkins] cpython: #15447: Use subprocess.DEVNULL in webbrowser, instead of opening
r.david.murray
python-checkins at python.org
Mon Sep 3 18:53:30 CEST 2012
http://hg.python.org/cpython/rev/901c790e4417
changeset: 78846:901c790e4417
user: R David Murray <rdmurray at bitdance.com>
date: Mon Sep 03 12:44:29 2012 -0400
summary:
#15447: Use subprocess.DEVNULL in webbrowser, instead of opening
This eliminates a ResourceWarning, since before webbrowser was
explicitly opening os.devnull and then leaving it open. Tests
to follow.
Patch by Anton Barkovsky.
files:
Lib/webbrowser.py | 4 ++--
Misc/NEWS | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -230,7 +230,7 @@
cmdline = [self.name] + raise_opt + args
if remote or self.background:
- inout = io.open(os.devnull, "r+")
+ inout = subprocess.DEVNULL
else:
# for TTY browsers, we need stdin/out
inout = None
@@ -354,7 +354,7 @@
else:
action = "openURL"
- devnull = io.open(os.devnull, "r+")
+ devnull = subprocess.DEVNULL
# if possible, put browser in separate process group, so
# keyboard interrupts don't affect browser as well as Python
setsid = getattr(os, 'setsid', None)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,9 @@
Library
-------
+- Issue #15447: Use subprocess.DEVNULL in webbrowser, instead of opening
+ os.devnull explicitly and leaving it open.
+
- Issue #15509: webbrowser.UnixBrowser no longer passes empty arguments to
Popen when %action substitutions produce empty strings.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list