Issue 24955: webbrowser broken on Mac OS X when using the BROWSER variable (original) (raw)

Created on 2015-08-29 10:01 by sconseil, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
webbrowser.patch sconseil,2015-08-29 10:17
24955.diff hudelgado,2020-07-27 03:16
Pull Requests
URL Status Linked Edit
PR 27751 open hudelgado,2021-08-13 01:45
Messages (13)
msg249316 - (view) Author: Simon Conseil (sconseil) * Date: 2015-08-29 10:01
Hi, There is an issue in the webbrowser module for Mac OS when the BROWSER environment variable is set: Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. Jedi is not installed, falling back to readline Python shell history: /Users/simon/.pythonhistory >>> import webbrowser Traceback (most recent call last): File "", line 1, in File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/webbrowser.py", line 669, in cmd = _synthesize(cmdline, -1) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/webbrowser.py", line 94, in _synthesize if controller and name.lower() == controller.basename: AttributeError: 'MacOSXOSAScript' object has no attribute 'basename' If I unset BROWSER then it works fine. The issue is that the MacOSXOSAScript class overrides BaseBrowser's init without redifining the basename attribute. So a simple fix is to remove the __init__ from MacOSXOSAScript (and I guess the same applies to the MacOSX class). The same issue applies to python 3.4
msg249317 - (view) Author: Simon Conseil (sconseil) * Date: 2015-08-29 10:17
New version of the patch to rename the _name attribute to name as in other BaseBrowser subclasses.
msg257198 - (view) Author: Erwann Mest (_kud) Date: 2015-12-29 16:20
+1 I've got like 3 apps which are broken. - https://github.com/mkdocs/mkdocs/issues/465 - https://bugzilla.mozilla.org/show_bug.cgi?id=1012443
msg257962 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2016-01-11 14:52
The patch is correct and will fix the issue. It will require test coverage to be complete so that we don't land upon similar issues in future.
msg258120 - (view) Author: Simon Conseil (sconseil) * Date: 2016-01-12 22:43
I have looked at the webbrowser tests and it seems not so easy: currently the MacOS browser classes are not tested, and they don't the GenericBrowser base class. Instead they use custom code with os.popen, so it would require some work either replace os.popen with subprocess.Popen, or to mock the os.popen calls. I'm not sure I will the time to dig into this.
msg258122 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2016-01-12 23:43
Simon, sure. It is just for someone, either commiters or other interested folks to add the tests on top of your patch. Agree with you that more change is required to add the required tests.
msg374220 - (view) Author: Hugo Delgado (hudelgado) * Date: 2020-07-25 02:19
I've bumped into this and won't mind working on it, is it ok for me to try to finish it?
msg374221 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2020-07-25 02:26
Hugo, please go ahead and a test for this patch.
msg374223 - (view) Author: Hugo Delgado (hudelgado) * Date: 2020-07-25 02:43
Ok, I'm thinking in also replace the os.popen calls with subprocess.Popen to keep consistency with existing tests. Do you think it's a good approach? Or should be better to just add some tests around the current implementation?
msg374231 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2020-07-25 03:48
Hugo, I'd welcome such a change.
msg374358 - (view) Author: Hugo Delgado (hudelgado) * Date: 2020-07-27 03:16
I took a look at it and have a some more questions. The class MacOSX(BaseBrowser) seems to be broken because it uses 'OpenUrl' which doesn't work in most recent versions of applescript, also that class doesn't seem to be used anywhere, is it ok to remove it, or should left it as is? Although that class isn't used it contained an hack to open local files that didn't exist in the class MacOSXOSAScript(BaseBrowser), i've added that hack to the MacOSXOSAScript. Can you validate if everything seems ok with this changes? I'm happy to adjust things according to what you suggest.
msg399394 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-08-11 13:59
Also see https://bugs.python.org/issue42255 Hugo: can you convert the patch to a PR?
msg399488 - (view) Author: Hugo Delgado (hudelgado) * Date: 2021-08-13 01:52
Yes, I've created a PR for it. https://github.com/python/cpython/pull/27751 Happy to adapt it as needed. Thanks
History
Date User Action Args
2022-04-11 14:58:20 admin set github: 69143
2021-08-17 16:46:29 corona10 set versions: + Python 3.11, - Python 2.7, Python 3.5, Python 3.6
2021-08-13 01:52:12 hudelgado set messages: +
2021-08-13 01:45:42 hudelgado set stage: test needed -> patch reviewpull_requests: + <pull%5Frequest26228>
2021-08-11 13:59:53 andrei.avk set nosy: + andrei.avkmessages: +
2020-07-27 03:16:47 hudelgado set files: + 24955.diffmessages: +
2020-07-25 03:48:06 orsenthil set messages: +
2020-07-25 02:43:30 hudelgado set messages: +
2020-07-25 02:26:41 orsenthil set assignee: orsenthilmessages: +
2020-07-25 02:19:38 hudelgado set nosy: + hudelgadomessages: +
2019-12-30 19🔞33 eitan.adler set nosy: + eitan.adler
2017-07-22 00:58:35 ehuss set nosy: + ehuss
2016-06-18 17:57:53 doughellmann set nosy: + doughellmann
2016-01-12 23:43:27 orsenthil set messages: +
2016-01-12 22:43:04 sconseil set messages: +
2016-01-11 14:52:30 orsenthil set versions: + Python 3.5, Python 3.6, - Python 3.4nosy: + orsenthilmessages: + stage: test needed
2015-12-29 16:20:53 _kud set nosy: + _kudmessages: +
2015-08-29 10:17:52 sconseil set files: - webbrowser.patch
2015-08-29 10:17:33 sconseil set files: + webbrowser.patchmessages: +
2015-08-29 10:01:40 sconseil create