-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
bpo-31014: webbrowser._synthesize
calls webbrowser.register
with outdated signature
#2689
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
@jmsdvl, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @freddrake and @serhiy-storchaka to be potential reviewers. |
webbrowser._synthesize
calls webbrowser.register
with outdated signature
@@ -113,7 +113,7 @@ def _synthesize(browser, update_tryorder=1): | |||
controller = copy.copy(controller) | |||
controller.name = browser | |||
controller.basename = os.path.basename(browser) | |||
register(browser, None, controller, update_tryorder) | |||
register(browser, None, instance=controller, preferred=update_tryorder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update_tryorder
is 1 or -1. preferred
is a boolean parameter. 1 and -1 both are true in boolean context.
I think that the update_tryorder
parameter of _synthesize()
should be replaced with boolean preferred
as in register()
(see bpo-24241).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update tryorder is now a boolean as requested.
To try and help move older pull requests forward, we are going through and backfilling 'awaiting' labels on pull requests that are lacking the label. Based on the current reviews, the best we can tell in an automated fashion is that a core developer requested changes to be made to this pull request. If/when the requested changes have been made, please leave a comment that says, |
@@ -113,7 +113,7 @@ def _synthesize(browser, update_tryorder=1): | |||
controller = copy.copy(controller) | |||
controller.name = browser | |||
controller.basename = os.path.basename(browser) | |||
register(browser, None, controller, update_tryorder) | |||
register(browser, None, instance=controller, preferred=update_tryorder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update tryorder is now a boolean as requested.
@@ -265,6 +267,23 @@ def test_register_default(self): | |||
def test_register_preferred(self): | |||
self._check_registration(preferred=True) | |||
|
|||
def test_environment_variable_BROWSER_is_respected(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does accurately catch the regression as far as I can tell but it seems a little obscure. Thoughts?
I have made the requested changes; please review again |
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
webbrowser._synthesize
calls webbrowser.register
with outdated signaturewebbrowser._synthesize
calls webbrowser.register
with outdated signature
I tried to write a less obscure test for the bug in def test_synthesize(self):
webbrowser = support.import_fresh_module('webbrowser')
name = os.path.basename(sys.executable).lower()
webbrowser.register(name, None, webbrowser.GenericBrowser(name))
webbrowser.get(sys.executable) |
def mock_which(path): | ||
return True | ||
|
||
class Test(test_webbrowser.ImportTest): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost missed that this re-ran the ImportTest
suite with BROWSER
set.
I think that's OK as a test case, but it would be clearer as part of a dedicated BrowserOverrideTest
class that's placed after ImportTest
(and mentions in a class level comment that it re-runs the ImportTest
cases in a subprocess with BROWSER
set.
Merged as #7267 with other tests. |
Co-Authored-By: Makdon <[email protected]>
Co-Authored-By: Makdon <[email protected]> (cherry picked from commit e6557d3) Co-authored-by: Xtreak <[email protected]>
Co-Authored-By: Makdon <[email protected]> (cherry picked from commit e6557d3) Co-authored-by: Xtreak <[email protected]>
Co-Authored-By: Makdon <[email protected]>
Tonight while running the test suite I noticed the following two errors with the tests for the
webbrowser
module:After a little bit of digging I discovered that
webbrowser_synthesize
is using an old call signature forwebbrowser.register
. This PR should fix that. I believe this is the only place the change in function signature was either affected or not updated.https://bugs.python.org/issue31014