]> granicus.if.org Git - python/commitdiff
#15447: Use subprocess.DEVNULL in webbrowser, instead of opening
authorR David Murray <rdmurray@bitdance.com>
Mon, 3 Sep 2012 16:44:29 +0000 (12:44 -0400)
committerR David Murray <rdmurray@bitdance.com>
Mon, 3 Sep 2012 16:44:29 +0000 (12:44 -0400)
This eliminates a ResourceWarning, since before webbrowser was
explicitly opening os.devnull and then leaving it open.  Tests
to follow.

Patch by Anton Barkovsky.

Lib/webbrowser.py
Misc/NEWS

index 861742538ec37f751809f7b8c137740b3b9fb908..94d4ad42e6ab25d568ccf46e6d472853e3afabb7 100644 (file)
@@ -230,7 +230,7 @@ class UnixBrowser(BaseBrowser):
         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 @@ class Konqueror(BaseBrowser):
         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)
index 93bc1dba61ac1916b42a882d1857eb5e2dbf0dd7..0463aa24a3b14317b5f19f3d883edc2812d80188 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,9 @@ Core and Builtins
 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.