Kaydet (Commit) 02ca144b authored tarafından R David Murray's avatar R David Murray

#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.
üst d674a770
...@@ -230,7 +230,7 @@ class UnixBrowser(BaseBrowser): ...@@ -230,7 +230,7 @@ class UnixBrowser(BaseBrowser):
cmdline = [self.name] + raise_opt + args cmdline = [self.name] + raise_opt + args
if remote or self.background: if remote or self.background:
inout = io.open(os.devnull, "r+") inout = subprocess.DEVNULL
else: else:
# for TTY browsers, we need stdin/out # for TTY browsers, we need stdin/out
inout = None inout = None
...@@ -354,7 +354,7 @@ class Konqueror(BaseBrowser): ...@@ -354,7 +354,7 @@ class Konqueror(BaseBrowser):
else: else:
action = "openURL" action = "openURL"
devnull = io.open(os.devnull, "r+") devnull = subprocess.DEVNULL
# if possible, put browser in separate process group, so # if possible, put browser in separate process group, so
# keyboard interrupts don't affect browser as well as Python # keyboard interrupts don't affect browser as well as Python
setsid = getattr(os, 'setsid', None) setsid = getattr(os, 'setsid', None)
......
...@@ -21,6 +21,9 @@ Core and Builtins ...@@ -21,6 +21,9 @@ Core and Builtins
Library 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 - Issue #15509: webbrowser.UnixBrowser no longer passes empty arguments to
Popen when %action substitutions produce empty strings. Popen when %action substitutions produce empty strings.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment