
Hi wonderful python folks, I was trying to use the webbrowser module with OS X's preinstalled python; I'm not very familiar with OS X, but I just patched webbrowser.py to use the very generic "open" command, which works for the simple webbrowser.open(url). I've heard that Fink or another port would be more complete; on the other hand, I'm using computers where I can't install software myself, so this is useful for me. Any thoughts or issues? -Brendan (student) --- webbrowser.py Mon Jan 12 11:43:26 2004 +++ /usr/lib/python2.2/webbrowser.py Sun Jul 14 23:33:32 2002 @@ -1,6 +1,4 @@ """Interfaces for launching and remotely controlling Web browsers.""" -#patched to work on os x native python - import os import sys @@ -299,15 +297,6 @@ # so don't mess with the default! _tryorder = ["internet-config"] register("internet-config", InternetConfig) - -# -# Platform support for OS X (builtin unix version) -# the os x 'open' command opens ANYTHING including url's. -# ISSUE: what if InternetConfig is present? Is this OK? - -if sys.platform[:6] == 'darwin' and _iscommand("open"): - _tryorder = ['open'] - register("osx", None, GenericBrowser("open %s")) # # Platform support for OS/2

On Jan 12, 2004, at 8:45 PM, Brendan O'Connor wrote:
Hi wonderful python folks,
I was trying to use the webbrowser module with OS X's preinstalled python; I'm not very familiar with OS X, but I just patched webbrowser.py to use the very generic "open" command, which works for the simple webbrowser.open(url).
I've heard that Fink or another port would be more complete; on the other hand, I'm using computers where I can't install software myself, so this is useful for me.
Any thoughts or issues?
As a brand-new user of Mac OS X, "open" appears to be the right solution to me, picking up whatever settings one may have made for a different browser than Safari, not requiring fink, etc, etc. However, we should probably double-check on pythonmac-sig, where the REAL Mac Pythonistas hang out... Alex

On Jan 12, 2004, at 2:59 PM, Alex Martelli wrote:
On Jan 12, 2004, at 8:45 PM, Brendan O'Connor wrote:
I was trying to use the webbrowser module with OS X's preinstalled python; I'm not very familiar with OS X, but I just patched webbrowser.py to use the very generic "open" command, which works for the simple webbrowser.open(url).
I've heard that Fink or another port would be more complete; on the other hand, I'm using computers where I can't install software myself, so this is useful for me.
Any thoughts or issues?
As a brand-new user of Mac OS X, "open" appears to be the right solution to me, picking up whatever settings one may have made for a different browser than Safari, not requiring fink, etc, etc. However, we should probably double-check on pythonmac-sig, where the REAL Mac Pythonistas hang out...
I don't think that this patch is necessary.. On my Mac OS X 10.3 machine (comes with Python 2.3.0), webbrowser.py uses Internet Config to launch the url (the 'ic' module). This is basically equivalent to the open command. It works like this: * Internet Config is an old MacOS API that's mapped to Launch Services which launches the URL with your preferred browser * open is a command line utility that uses the NSWorkspace Cocoa API which uses Launch Services to launch the URL with your preferred browser I don't think your patch fixes anything, it's launched by Launch Services either way.. at least on OS X 10.3. A patch doesn't do us any good against Python 2.2.0 on Mac OS 10.2 if its behavior is broken. Apple doesn't update Python between major releases. You should be able to install MacPython 2.3 in your home directory. Don't bother with Fink. -bob

Bob> * Internet Config is an old MacOS API that's mapped to Launch Bob> Services which launches the URL with your preferred browser If Internet Config is an "old MacOS API" will it eventually disappear? Skip

On Jan 12, 2004, at 3:22 PM, Skip Montanaro wrote:
Bob> * Internet Config is an old MacOS API that's mapped to Launch Bob> Services which launches the URL with your preferred browser
If Internet Config is an "old MacOS API" will it eventually disappear?
In a few years, and if hell freezes over, maybe. It's recommended that new software uses System Configuration and Launch Services to replace Internet Config usage, but disabling Internet Config would break a whole lot of Carbon software. Python doesn't have an official wrapper for System Configuration (though I have one available), and the Launch Services wrapper is new for Python 2.4. -bob

On 12 jan 2004, at 21:16, Bob Ippolito wrote:
On Jan 12, 2004, at 2:59 PM, Alex Martelli wrote:
On Jan 12, 2004, at 8:45 PM, Brendan O'Connor wrote:
I was trying to use the webbrowser module with OS X's preinstalled python; I'm not very familiar with OS X, but I just patched webbrowser.py to use the very generic "open" command, which works for the simple webbrowser.open(url).
I've heard that Fink or another port would be more complete; on the other hand, I'm using computers where I can't install software myself, so this is useful for me.
Any thoughts or issues?
As a brand-new user of Mac OS X, "open" appears to be the right solution to me, picking up whatever settings one may have made for a different browser than Safari, not requiring fink, etc, etc. However, we should probably double-check on pythonmac-sig, where the REAL Mac Pythonistas hang out...
I don't think that this patch is necessary..
It might even be insecure, open will open more than just URLs (try 'open /bin/ls'). Ronald

On Jan 13, 2004, at 1:13 AM, Ronald Oussoren wrote:
On 12 jan 2004, at 21:16, Bob Ippolito wrote:
On Jan 12, 2004, at 2:59 PM, Alex Martelli wrote:
On Jan 12, 2004, at 8:45 PM, Brendan O'Connor wrote:
I was trying to use the webbrowser module with OS X's preinstalled python; I'm not very familiar with OS X, but I just patched webbrowser.py to use the very generic "open" command, which works for the simple webbrowser.open(url).
I've heard that Fink or another port would be more complete; on the other hand, I'm using computers where I can't install software myself, so this is useful for me.
Any thoughts or issues?
As a brand-new user of Mac OS X, "open" appears to be the right solution to me, picking up whatever settings one may have made for a different browser than Safari, not requiring fink, etc, etc. However, we should probably double-check on pythonmac-sig, where the REAL Mac Pythonistas hang out...
I don't think that this patch is necessary..
It might even be insecure, open will open more than just URLs (try 'open /bin/ls').
insecure?
from __future__ import audited_code File "<stdin>", line 1 SyntaxError: future feature audited_code is not defined
FWIW, ic.launchurl('file:///bin/ls') will do the same thing: open a Terminal.app window and execute /bin/ls. Safari will open a Finder window at "/bin" and select the "ls" executable. I'm not sure where the code is that handles unsafe URLs differently, but it's probably somewhere near WebCore.. probably not in Safari itself? I'd have to care, then I'd have to look :) -bob

I don't think that this patch is necessary.. On my Mac OS X 10.3 machine (comes with Python 2.3.0), webbrowser.py uses Internet Config to launch the url (the 'ic' module). This is basically equivalent to the open command. It works like this: * Internet Config is an old MacOS API that's mapped to Launch Services which launches the URL with your preferred browser * open is a command line utility that uses the NSWorkspace Cocoa API which uses Launch Services to launch the URL with your preferred browser
I don't think your patch fixes anything, it's launched by Launch Services either way.. at least on OS X 10.3. A patch doesn't do us any good against Python 2.2.0 on Mac OS 10.2 if its behavior is broken. Apple doesn't update Python between major releases.
You should be able to install MacPython 2.3 in your home directory. Don't bother with Fink.
That's it, I'm on 10.2; I guess this is just a quick fix for that one version. Well, thanks all for the pointers. -Brendan

(python-dev is not the best place for this. If you want to submit a proposed patch, please use the SourceForge bug tracker. For more "how do I do this" sorts of stuff, please use comp.lang.python (aka python-list@python.org). Your post sort of straddles both domains.) Brendan> I was trying to use the webbrowser module with OS X's Brendan> preinstalled python; I'm not very familiar with OS X, but I Brendan> just patched webbrowser.py to use the very generic "open" Brendan> command, which works for the simple webbrowser.open(url). ... Brendan> Any thoughts or issues? All you need to do to get this to work is set your BROWSER environment variable to "open": % env | grep BROWSER BROWSER=open No source mods necessary. Skip
participants (5)
-
Alex Martelli
-
Bob Ippolito
-
Brendan O'Connor
-
Ronald Oussoren
-
Skip Montanaro