-
-
Notifications
You must be signed in to change notification settings - Fork 31.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
webbrowser broken on Mac OS X when using the BROWSER variable #69143
Comments
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 "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/webbrowser.py", line 669, in <module>
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 |
New version of the patch to rename the _name attribute to name as in other BaseBrowser subclasses. |
+1 I've got like 3 apps which are broken. |
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. |
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. |
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. |
I've bumped into this and won't mind working on it, is it ok for me to try to finish it? |
Hugo, please go ahead and a test for this patch. |
Ok, I'm thinking in also replace the os.popen calls with subprocess.Popen to keep consistency with existing tests. |
Hugo, I'd welcome such a change. |
I took a look at it and have a some more questions. |
Also see https://bugs.python.org/issue42255 Hugo: can you convert the patch to a PR? |
Yes, I've created a PR for it. Happy to adapt it as needed. |
This works in the current releases for 3.9, 3.10, 3.11 and 3.12: That means this issue is no longer needed. |
I do not see the behavior that @ronaldoussoren describes:
Chrome is my default browser, but sometimes it is helpful to be able to test in Safari. |
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: