]> granicus.if.org Git - python/commitdiff
Fix webbrowser.BackgroundBrowser on Windows.
authorGeorg Brandl <georg@python.org>
Sun, 24 Sep 2006 10:36:08 +0000 (10:36 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 24 Sep 2006 10:36:08 +0000 (10:36 +0000)
 (backport from rev. 51991)

Lib/webbrowser.py
Misc/NEWS

index 7a1a3b4994c0d1b9b0ada43824328bdb39089d17..7b0f7367dbf09bb512621c94d57005151c96a657 100644 (file)
@@ -165,7 +165,10 @@ class GenericBrowser(BaseBrowser):
         cmdline = [self.name] + [arg.replace("%s", url)
                                  for arg in self.args]
         try:
-            p = subprocess.Popen(cmdline, close_fds=True)
+            if sys.platform[:3] == 'win':
+                p = subprocess.Popen(cmdline)
+            else:
+                p = subprocess.Popen(cmdline, close_fds=True)
             return not p.wait()
         except OSError:
             return False
@@ -178,11 +181,14 @@ class BackgroundBrowser(GenericBrowser):
     def open(self, url, new=0, autoraise=1):
         cmdline = [self.name] + [arg.replace("%s", url)
                                  for arg in self.args]
-        setsid = getattr(os, 'setsid', None)
-        if not setsid:
-            setsid = getattr(os, 'setpgrp', None)
         try:
-            p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
+            if sys.platform[:3] == 'win':
+                p = subprocess.Popen(cmdline)
+            else:
+                setsid = getattr(os, 'setsid', None)
+                if not setsid:
+                    setsid = getattr(os, 'setpgrp', None)
+                p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
             return (p.poll() is None)
         except OSError:
             return False
index 5a539db3273a20576d5e8cafd62c10db1244faa7..b6087a906f75736ee21441d5bbabc7468e787da0 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,12 +14,21 @@ Core and builtins
 
 - Allow exception instances to be directly sliced again.
 
+
 Extension Modules
 -----------------
 
 - Fix itertools.count(n) to work with negative numbers again.
 
 
+Library
+-------
+
+- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because
+  the close_fds arg to subprocess.Popen is not supported).
+
+
+
 What's New in Python 2.5 (final)
 ================================
 
@@ -27,6 +36,7 @@ What's New in Python 2.5 (final)
 
 No changes since release candidate 2.
 
+
 What's New in Python 2.5 release candidate 2?
 =============================================