This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: UnixBrowser.open sometimes passes zero-length argument to the browser.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: anton.barkovsky, asvetlov, ezio.melotti, georg.brandl, python-dev, r.david.murray, tshepang
Priority: normal Keywords: patch

Created on 2012-07-30 22:35 by anton.barkovsky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
webbrowser_args.patch anton.barkovsky, 2012-07-30 22:39 review
Messages (6)
msg166930 - (view) Author: Anton Barkovsky (anton.barkovsky) * Date: 2012-07-30 22:35
Because of the way webbrowser.UnixBrowser.open generates command-line
arguments the resulting list sometimes looks like this:

  ['chromium', '', 'http://www.example.org/']

This seems to work fine with chromium for me but as you can see:

  >>> subprocess.call(['ls', '', '-l'])
  ls: cannot access : No such file or directory
  2

It's not a good idea to rely on that.
I'm attaching a patch that filters out those empty arguments.
msg167425 - (view) Author: Anton Barkovsky (anton.barkovsky) * Date: 2012-08-04 17:55
Added tests in #15557.
msg168090 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-08-13 12:29
Better to fix producer of empty lines than filter those ones.
Keep in mind: there are several places there args list generated, probably you fix not all error sources.
msg169770 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-09-03 16:15
Given the logic of webbrowser, I think Anton's patch is correct.  The null strings are produced by the somewhat twisted logic of UnixBrowser.open, and the problem doesn't apply to the other cases of argument list generation.  (In those other cases, getting null strings would indicate a configuration error, which this case is not.)
msg169776 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-09-03 16:53
New changeset 6768aa70c2d3 by R David Murray in branch '3.2':
#15509: If %action substitution produces a null string, drop it.
http://hg.python.org/cpython/rev/6768aa70c2d3

New changeset 323ca2f0e382 by R David Murray in branch 'default':
Merge #15509: If %action substitution produces a null string, drop it.
http://hg.python.org/cpython/rev/323ca2f0e382

New changeset 5da3b2df38b3 by R David Murray in branch 'default':
#15557,#15447,#15509: webbrowser test suite added.
http://hg.python.org/cpython/rev/5da3b2df38b3
msg169778 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-09-03 16:54
Thanks, Anton.
History
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59714
2012-09-03 16:54:46r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg169778

stage: test needed -> resolved
2012-09-03 16:53:26python-devsetnosy: + python-dev
messages: + msg169776
2012-09-03 16:16:33r.david.murraysettitle: webbrowser.open sometimes passes zero-length argument to the browser. -> UnixBrowser.open sometimes passes zero-length argument to the browser.
2012-09-03 16:15:43r.david.murraysetnosy: + r.david.murray
messages: + msg169770
2012-08-13 12:29:11asvetlovsetnosy: + asvetlov
messages: + msg168090
2012-08-09 13:22:11asvetlovlinkissue15557 dependencies
2012-08-06 08:38:26tshepangsetnosy: + tshepang
2012-08-04 17:55:06anton.barkovskysetmessages: + msg167425
2012-07-30 23:03:15ezio.melottisetnosy: + georg.brandl, ezio.melotti
stage: test needed

versions: + Python 2.7, Python 3.2
2012-07-30 22:39:40anton.barkovskysetfiles: + webbrowser_args.patch
2012-07-30 22:39:23anton.barkovskysetfiles: - webbrowser_args.patch
2012-07-30 22:35:17anton.barkovskycreate