[Python-Dev] unicode imports

Nick Coghlan ncoghlan at gmail.com
Sat Jun 17 06:44:54 CEST 2006


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.

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.

I guess we could create a Py_GetPathEx and a PySys_SetPathEx that accepted the 
delimeters as arguments, and change the call in pythonrun.c from:

   PySys_SetPath(Py_GetPath())

to:

   PySys_SetPathEx(Py_GetPathEx(';'), ';')

(still an incompatible change, but an easier to manage one since you can 
easily provide different behavior for earlier versions of Python)

> which probably also 
> has to change in order to make unicode directories work on Win32 (though 
> I think there may be a separate win32 implementation of getpath).

There is - PC/getpathp.c

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list