summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-10-24 22:21:02 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-10-24 22:21:02 (GMT)
commitb528fcf9540dc2db5217e3388e9fc81dce08b70f (patch)
tree4c993a4bcd59e124acdcd7cda4c2d9c3d53d7f77 /Python
parent08a95cabe3ba7311d8a2327dc3d7e3e490e23333 (diff)
downloadcpython-b528fcf9540dc2db5217e3388e9fc81dce08b70f.zip
cpython-b528fcf9540dc2db5217e3388e9fc81dce08b70f.tar.gz
cpython-b528fcf9540dc2db5217e3388e9fc81dce08b70f.tar.bz2
Fix test_imp failure under Windows
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index e21ae39..3842c63 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -938,12 +938,19 @@ make_compiled_pathname(PyObject *pathstr, int debug)
Py_ssize_t pycache_len = sizeof(CACHEDIR) - 1;
int kind;
void *data;
+ Py_UCS4 lastsep;
/* Compute the output string size. */
len = PyUnicode_GET_LENGTH(pathstr);
/* If there is no separator, this returns -1, so
- lastsep will be 0. */
+ fname will be 0. */
fname = rightmost_sep_obj(pathstr, 0, len) + 1;
+ /* Windows: re-use the last separator character (/ or \\) when
+ appending the __pycache__ path. */
+ if (fname > 0)
+ lastsep = PyUnicode_READ_CHAR(pathstr, fname -1);
+ else
+ lastsep = SEP;
ext = fname - 1;
for(i = fname; i < len; i++)
if (PyUnicode_READ_CHAR(pathstr, i) == '.')
@@ -965,7 +972,7 @@ make_compiled_pathname(PyObject *pathstr, int debug)
pos = fname;
for (i = 0; i < pycache_len; i++)
PyUnicode_WRITE(kind, data, pos++, CACHEDIR[i]);
- PyUnicode_WRITE(kind, data, pos++, SEP);
+ PyUnicode_WRITE(kind, data, pos++, lastsep);
PyUnicode_CopyCharacters(result, pos, pathstr,
fname, ext - fname);
pos += ext - fname;