Commit d57e8768 authored by Amaury Forgeot d'Arc's avatar Amaury Forgeot d'Arc

Second part of #3187, for windows:

os and os.path functions now accept both unicode and byte strings for file names.

Reviewed by Guido.
parent 4ac18c23
This diff is collapsed.
......@@ -12,6 +12,23 @@ def tester(fn, wantResult):
raise TestFailed("%s should return: %s but returned: %s" \
%(str(fn), str(wantResult), str(gotResult)))
# then with bytes
fn = fn.replace("('", "(b'")
fn = fn.replace('("', '(b"')
fn = fn.replace("['", "[b'")
fn = fn.replace('["', '[b"')
fn = fn.replace(", '", ", b'")
fn = fn.replace(', "', ', b"')
gotResult = eval(fn)
if isinstance(wantResult, str):
wantResult = wantResult.encode('ascii')
elif isinstance(wantResult, tuple):
wantResult = tuple(r.encode('ascii') for r in wantResult)
gotResult = eval(fn)
if wantResult != gotResult:
raise TestFailed("%s should return: %s but returned: %s" \
%(str(fn), str(wantResult), repr(gotResult)))
class TestNtpath(unittest.TestCase):
def test_splitext(self):
......
......@@ -1651,7 +1651,7 @@ static PyObject *
posix_chdir(PyObject *self, PyObject *args)
{
#ifdef MS_WINDOWS
return win32_1str(args, "chdir", "s:chdir", win32_chdir, "U:chdir", win32_wchdir);
return win32_1str(args, "chdir", "y:chdir", win32_chdir, "U:chdir", win32_wchdir);
#elif defined(PYOS_OS2) && defined(PYCC_GCC)
return posix_1str(args, "et:chdir", _chdir2);
#elif defined(__VMS)
......@@ -2586,7 +2586,7 @@ static PyObject *
posix_rmdir(PyObject *self, PyObject *args)
{
#ifdef MS_WINDOWS
return win32_1str(args, "rmdir", "s:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW);
return win32_1str(args, "rmdir", "y:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW);
#else
return posix_1str(args, "et:rmdir", rmdir);
#endif
......@@ -2667,7 +2667,7 @@ static PyObject *
posix_unlink(PyObject *self, PyObject *args)
{
#ifdef MS_WINDOWS
return win32_1str(args, "remove", "s:remove", DeleteFileA, "U:remove", DeleteFileW);
return win32_1str(args, "remove", "y:remove", DeleteFileA, "U:remove", DeleteFileW);
#else
return posix_1str(args, "et:remove", unlink);
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment