[Python-Dev] unicode imports

Ronald Oussoren ronaldoussoren at mac.com
Sat Jun 17 18:04:54 CEST 2006


On 17-jun-2006, at 6:44, Nick Coghlan wrote:

> Bob Ippolito wrote:
>> There's a similar issue in that if sys.prefix contains a colon,  
>> Python
>> is also busted:
>> http://python.org/sf/1507224
>>
>> Of course, that's not a Windows issue, but it is everywhere else. The
>> offending code in that case is Modules/getpath.c,
>
> Since it has to do with the definition of Py_GetPath as returning a  
> single
> string that is really a DELIM separated list of strings, where  
> DELIM is
> defined by the current platform (';' on Windows, ':' everywhere  
> else), this
> seems more like a platform problem than a Python problem, though -  
> you can't
> have directories containing a colon as an entry in PATH or  
> PYTHONPATH either.
> It's not really Python's fault that the platform defines a legal  
> filename
> character as the delimiter for path entries.

On unix-y systems any character except the NUL byte can be used in a  
legal fileystem path, that leaves awfully little characters to use as  
delimiter without risking issues like the one in the bug Bob mentioned.

>
> The only real alternative I can see is to normalise Py_GetPath to  
> always
> return a ';' delimited list of strings, regardless of platform, and  
> update
> PySys_SetPath accordingly. That'd cause potential compatibility  
> problems for
> embedded interpreters, though.

That wouldn't help, ';' is also a valid character in filenames on  
Unix.  Except for accepting the status quo (which is a perfectly fine  
alternative) there seem to be two valid ways to solve this problem.  
You can either define Py_GetPath2 that returns a python list or  
tuple, or introduce some way of quoting the delimiter. Both would be  
backward incompatible.

Ronald


More information about the Python-Dev mailing list