#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.
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 8617425..94d4ad4 100644
--- 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)