]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#15509: If %action substitution produces a null string, drop it.
authorR David Murray <rdmurray@bitdance.com>
Mon, 3 Sep 2012 16:30:12 +0000 (12:30 -0400)
committerR David Murray <rdmurray@bitdance.com>
Mon, 3 Sep 2012 16:30:12 +0000 (12:30 -0400)
Patch by Anton Barkovsky, comment addition by me.

This showed up as a bug in 3.3 because the definition for Chrome
produced such an empty string.  This fix is tested in 3.3+;
backporting the new test suite is more trouble than it is worth.

Lib/webbrowser.py
Misc/NEWS

index 6f967b61cf2fb0130d7de5874b93c03beeec71fe..202f34a1a2e02a6b974d05b6669096195c496420 100644 (file)
@@ -206,12 +206,18 @@ class UnixBrowser(BaseBrowser):
     """Parent class for all Unix browsers with remote functionality."""
 
     raise_opts = None
+    background = False
+    redirect_stdout = True
+    # In remote_args, %s will be replaced with the requested URL.  %action will
+    # be replaced depending on the value of 'new' passed to open.
+    # remote_action is used for new=0 (open).  If newwin is not None, it is
+    # used for new=1 (open_new).  If newtab is not None, it is used for
+    # new=3 (open_new_tab).  After both substitutions are made, any empty
+    # strings in the transformed remote_args list will be removed.
     remote_args = ['%action', '%s']
     remote_action = None
     remote_action_newwin = None
     remote_action_newtab = None
-    background = False
-    redirect_stdout = True
 
     def _invoke(self, args, remote, autoraise):
         raise_opt = []
@@ -267,6 +273,7 @@ class UnixBrowser(BaseBrowser):
 
         args = [arg.replace("%s", url).replace("%action", action)
                 for arg in self.remote_args]
+        args = [arg for arg in args if arg]
         success = self._invoke(args, True, autoraise)
         if not success:
             # remote invocation failed, try straight way
index 544bf67afb26521aa8ea4ca9fcf74764d163e036..93b679b37ffb0546f7e9c566be4ca36d59887684 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -115,6 +115,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #15509: webbrowser.UnixBrowser no longer passes empty arguments to
+  Popen when %action substitutions produce empty strings.
+
 - Issue #12776,#11839: call argparse type function (specified by add_argument)
   only once. Before, the type function was called twice in the case where the
   default was specified and the argument was given as well.  This was