New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webbrowser default browser detection and/or public API for _trylist. #68429
Comments
When calling webbrowser.open*(), the module goes through a list of installed browsers, and uses the first one that succeeds, to process the request. The first 'browsers' in the 'X' list are 'xdg-open' and others of that ilk. The problem is that they only have one 'open' behavior - the 'new' parameter is ignored ('same window', 'new window', 'new tab'). I can get the fully supported default browser in GNOME with e.g. def browser():
app = Gio.app_info_get_default_for_type('x-scheme-handler/https', True)
bpath = app.get_filename()
for candidate in webbrowser._tryorder:
if candidate in bpath:
return webbrowser.get(using=candidate)
return webbrowser.get() ... but this code accesses a private list. The problems are:
The problem can be mitigated by resolving (1) and/or (2). Also, the browser type list in the documentation is missing many entries. Checked on 2.7 and 3.4. I believe this is valid across all supported versions. |
Any change is going to be an enhancement, so it will only go in 3.6 (at this point...beta/feature freeze for 3.5 is this weekend). Would you like to propose a patch? |
On Tue, May 19, 2015 at 10:19 AM, R. David Murray
My preferred solution would be a bit intrusive - check for and use |
Patch attached, to sort the desktop default browser to the top of _tryorder. |
See #85 |
Hello David, |
Jaysinh, Thanks for the feedback. I'm adding the documentation now. As I noted in github, I'm not sure what the preferred exception handling would be for xdg-settings. |
To summarise the changes that were made during the PR review, here's the eventual commit message for the merged PR: ============
The first change replaces the existing undocumented tri-state The second change adds a private |
After merging this, I belatedly realised that codecov's complaint about the lack of code coverage for the diff was actually valid: now that "preferred" is a public API, it should have a cross-platform test case. That should be a fairly straightforward test to write, as it can just use an arbitrary string, and then poke around in _tryorder directly to make sure it is updated as expected - it doesn't need to use a valid browser reference. |
Second PR merged with the missing test case. |
It seems like this issue introduced a regression: bpo-33693. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: