Bugs item #1507224, was opened at 2006-06-16 13:22 Message generated for change (Comment added) made by ronaldoussoren You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1507224&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Ronald Oussoren (ronaldoussoren) Assigned to: Nobody/Anonymous (nobody) Summary: sys.path issue if sys.prefix contains a colon Initial Comment: If you install python in a directory whose path contains a colon sys.path will be wrong, the installation directory will be split into two strings and both of them are added to sys.path. The following session demonstrates the problem: 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'] ---------------------------------------------------------------------- >Comment By: Ronald Oussoren (ronaldoussoren) Date: 2006-06-25 23:07 Message: Logged In: YES user_id=580910 One way to fix this to redefine Py_GetPath to return some kind of array instead string that is formatted like PYTHONPATH. Another option is returning a string where path elements are seperated by NUL bytes (with two NUL bytes at the end to make it possible to find the end of the path). A problem with this is that this would make it impossible to have empty strings in your PYTHONPATH (such as 'somedir::otherdir'). Both options have the disadvantage that they change a public interface (embedders can reimplement Py_GetPath to get full control over the construction of sys.path). BTW. This bug was found by a user of py2app, a py2exe-like tool for macosx. A user of his application complained that the application didn't run when it was stored in a directory with colons in its name. ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2006-06-25 12:16 Message: Logged In: YES user_id=21627 The issue is not with environment variables at all; they play no role in this bug report. There is no convention for an escape mechanism in environment variables, and we should not introduce one, but again, this report is not about environment variables. ---------------------------------------------------------------------- Comment By: Armin Rigo (arigo) Date: 2006-06-25 12:04 Message: Logged In: YES user_id=4771 Internally, CPython sets up its path using a single ':'-separated string. I have no clue how, on Posix, you are supposed to use paths containing ':' in environment variables like $PATH - escape the colons somehow? If there is some escape mechanism, we could support it, both as an internal way to fix the present issue, and directly in parsing PYTHONPATH. If there is no such mechanism, then I can only conclude that having colons in paths will make many other things unhappy, not just Python. ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2006-06-24 12:35 Message: Logged In: YES user_id=21627 I think this can be fixed. sys.prefix should be treated as unspittable when constructing sys.path, i.e. sys.prefix should be inserted only after the colon-splitting has been done. Not sure what the best way to implement that would be, though, so unassigning. ---------------------------------------------------------------------- Comment By: Georg Brandl (gbrandl) Date: 2006-06-22 21:08 Message: Logged In: YES user_id=849994 I don't know if something can be done here. A possibility would be, if one path segment doesn't exist, add the colon and the next segment and try again. Martin, do you have an opinion? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1507224&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com