[Python-checkins] r80698 - in python/trunk: Lib/webbrowser.py Misc/NEWS
ronald.oussoren
python-checkins at python.org
Sun May 2 11:48:21 CEST 2010
Author: ronald.oussoren
Date: Sun May 2 11:48:21 2010
New Revision: 80698
Log:
For for issue #7192: with this patch webbrowser.get("firefox")
works on OSX
Modified:
python/trunk/Lib/webbrowser.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/webbrowser.py
==============================================================================
--- python/trunk/Lib/webbrowser.py (original)
+++ python/trunk/Lib/webbrowser.py Sun May 2 11:48:21 2010
@@ -599,9 +599,35 @@
rc = osapipe.close()
return not rc
+ class MacOSXOSAScript(BaseBrowser):
+ def __init__(self, name):
+ self._name = name
+
+ def open(self, url, new=0, autoraise=True):
+ if self._name == 'default':
+ script = 'open location "%s"' % url.replace('"', '%22') # opens in default browser
+ else:
+ script = '''
+ tell application "%s"
+ activate
+ open location "%s"
+ end
+ '''%(self._name, url.replace('"', '%22'))
+
+ osapipe = os.popen("osascript", "w")
+ if osapipe is None:
+ return False
+
+ osapipe.write(script)
+ rc = osapipe.close()
+ return not rc
+
+
# Don't clear _tryorder or _browsers since OS X can use above Unix support
# (but we prefer using the OS X specific stuff)
- register("MacOSX", None, MacOSX('default'), -1)
+ register("MacOSX", None, MacOSXOSAScript('default'), -1)
+ register("safari", None, MacOSXOSAScript('safari'), -1)
+ register("firefox", None, MacOSXOSAScript('firefox'), -1)
#
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sun May 2 11:48:21 2010
@@ -31,6 +31,9 @@
Library
-------
+- Issue #7192: webbrowser.get("firefox") now wors on Mac OS X, as does
+ webbrowser.get("safari").
+
- Issue #8577: distutils.sysconfig.get_python_inc() now makes a difference
between the build dir and the source dir when looking for "python.h" or
"Include".
More information about the Python-checkins
mailing list