[Pythonmac-SIG] py2app crash if path contains a colon

Bob Ippolito bob at redivi.com
Wed Jun 14 17:18:10 CEST 2006


python itself needs to be in a directory containing a colon.

bump:~/src/python/:colon bob$ ./python.exe -c "import sys; print  
sys.path"
'import site' failed; use -v for traceback
['', '/usr/local/lib/python25.zip', '/Users/bob/src/python/',  
'colon/../Lib/', '/Users/bob/src/python/', 'colon/../Lib/plat- 
darwin', '/Users/bob/src/python/', 'colon/../Lib/plat-mac', '/Users/ 
bob/src/python/', 'colon/../Lib/plat-mac/lib-scriptpackages', '/Users/ 
bob/src/python/', 'colon/../Lib/lib-tk', '/Users/bob/src/python/',  
'colon/Modules']

-bob

On Jun 14, 2006, at 2:51 AM, Ronald Oussoren wrote:

> Could either of you file a bug about this (the sys.path mangling  
> when there's a colon in the directory that contains the executable)  
> on python's SF tracker? Preferably including decription of how to  
> reproduce this.
>
> Bob, I've created a directory 'test:dir' and added a script named  
> 'test.py' in that directory that prints sys.path. If I run 'python  
> test:dir/test.py' sys.path[0] looks correct (including the colon in  
> test:dir).
>
> Ronald
>
> On Wednesday, June 14, 2006, at 10:21AM, Bob Ippolito  
> <bob at redivi.com> wrote:
>
>> On Jun 12, 2006, at 4:52 PM, Bob Swerdlow wrote:
>>
>>> Hi, our app is using py2app 0.2.1 and we've been quite happy with  
>>> it -
>>> thanks!
>>>
>>> However, we have found that it crashes if the application is
>>> started in a
>>> folder whose name contains a colon.  Of course, the Finder does not
>>> allow
>>> the user to use a colon in file names, but other applications do.
>>> According
>>> to the user:
>>
>> In Carbon APIs, these colons are represented by '/' (the POSIX path
>> delimiter)... from Finder (and I think also at the lowest level HFS+
>> APIs), that path looks like "6/10/06". Anything using the POSIX APIs
>> is going to see "6:10:06" though.
>>
>>> Is this a known problem?  Is there a work-around?
>>
>> It's a problem with Python actually, which persists even in the
>> trunk. Probably because a colon is often treated as a delimiter for a
>> list of paths (such as the PATH or PYTHONPATH environment variables).
>> If you run Python from a path containing ':' and look at sys.path,
>> you'll see that the paths that would've contained a colon are
>> mangled. I'm not sure where this happens and I don't have time to
>> track it down at the moment.
>>
>> It won't be possible to work around this without patching the Python
>> interpreter. For now you'll just have to tell your users Don't Do
>> That. I can only think of two workarounds:
>> (1) just tell the user that they can't run the app from a path
>> containing a ":" in a relatively friendly manner (could be done in
>> the py2app bootstrap).
>> (2) make a symlink somewhere from the py2app bootstrap if a ":" is in
>> the working directory and re-exec.
>>
>> I'm unlikely to do either of those things any time soon, but patches
>> are accepted. If you come up with a patch for Python, file it on
>> sourceforge and shoot a message referencing it here and someone will
>> definitely apply it. I'd hurry up though, because Python 2.5 is
>> pretty far along.
>>
>> -bob
>>
>> _______________________________________________
>> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
>> http://mail.python.org/mailman/listinfo/pythonmac-sig
>>
>>



More information about the Pythonmac-SIG mailing list