summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Hammond <mhammond@skippinet.com.au>2002-10-08 02:44:31 (GMT)
committerMark Hammond <mhammond@skippinet.com.au>2002-10-08 02:44:31 (GMT)
commit8696ebcd28d38f74ee0ffa2cd82d9db1c0bad8df (patch)
tree1d688f1ea3f3b785a19760dd1477b796370c698d /Lib
parent20eae69a9fb5b5453f9ddf01600f99fd6ffffed7 (diff)
downloadcpython-8696ebcd28d38f74ee0ffa2cd82d9db1c0bad8df.zip
cpython-8696ebcd28d38f74ee0ffa2cd82d9db1c0bad8df.tar.gz
cpython-8696ebcd28d38f74ee0ffa2cd82d9db1c0bad8df.tar.bz2
Add os.path.supports_unicode_filenames for all platforms,
sys.getwindowsversion() on Windows (new enahanced Tim-proof <wink> version), and fix test_pep277.py in a few minor ways. Including doc and NEWS entries.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/dospath.py4
-rw-r--r--Lib/macpath.py5
-rw-r--r--Lib/ntpath.py6
-rw-r--r--Lib/os2emxpath.py5
-rw-r--r--Lib/posixpath.py5
-rw-r--r--Lib/test/output/test_pep2772
-rw-r--r--Lib/test/test_pep277.py9
7 files changed, 25 insertions, 11 deletions
diff --git a/Lib/dospath.py b/Lib/dospath.py
index f613a63..345b940 100644
--- a/Lib/dospath.py
+++ b/Lib/dospath.py
@@ -6,7 +6,8 @@ import stat
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","islink","exists","isdir","isfile","ismount",
- "walk","expanduser","expandvars","normpath","abspath"]
+ "walk","expanduser","expandvars","normpath","abspath",
+ "supports_unicode_filenames"]
def normcase(s):
"""Normalize the case of a pathname.
@@ -336,3 +337,4 @@ def abspath(path):
# realpath is a no-op on systems without islink support
realpath = abspath
+supports_unicode_filenames = False
diff --git a/Lib/macpath.py b/Lib/macpath.py
index 8546892..f19b4f7 100644
--- a/Lib/macpath.py
+++ b/Lib/macpath.py
@@ -6,7 +6,8 @@ from stat import *
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","islink","exists","isdir","isfile",
- "walk","expanduser","expandvars","normpath","abspath"]
+ "walk","expanduser","expandvars","normpath","abspath",
+ "supports_unicode_filenames"]
# Normalize the case of a pathname. Dummy in Posix, but <s>.lower() here.
@@ -248,3 +249,5 @@ def realpath(path):
path = join(path, c)
path = macfs.ResolveAliasFile(path)[0].as_pathname()
return path
+
+supports_unicode_filenames = False
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index d376065..73b7a2f 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -7,11 +7,13 @@ module as os.path.
import os
import stat
+import sys
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","islink","exists","isdir","isfile","ismount",
- "walk","expanduser","expandvars","normpath","abspath","splitunc"]
+ "walk","expanduser","expandvars","normpath","abspath","splitunc",
+ "supports_unicode_filenames"]
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
@@ -476,3 +478,5 @@ def abspath(path):
# realpath is a no-op on systems without islink support
realpath = abspath
+# Win9x family and earlier have no Unicode filename support.
+supports_unicode_filenames = sys.getwindowsversion()[3] >= 2
diff --git a/Lib/os2emxpath.py b/Lib/os2emxpath.py
index a539a82..616d474 100644
--- a/Lib/os2emxpath.py
+++ b/Lib/os2emxpath.py
@@ -11,7 +11,8 @@ import stat
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","islink","exists","isdir","isfile","ismount",
- "walk","expanduser","expandvars","normpath","abspath","splitunc"]
+ "walk","expanduser","expandvars","normpath","abspath","splitunc",
+ "supports_unicode_filenames"]
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
@@ -400,3 +401,5 @@ def abspath(path):
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)
+
+supports_unicode_filenames = False
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index d5d2621..bf15390 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -17,7 +17,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","islink","exists","isdir","isfile","ismount",
"walk","expanduser","expandvars","normpath","abspath",
- "samefile","sameopenfile","samestat"]
+ "samefile","sameopenfile","samestat","supports_unicode_filenames"]
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
# On MS-DOS this may also turn slashes into backslashes; however, other
@@ -409,3 +409,6 @@ symbolic links encountered in the path."""
return realpath(newpath)
return filename
+
+supports_unicode_filenames = False
+
diff --git a/Lib/test/output/test_pep277 b/Lib/test/output/test_pep277
index 717b707..43bd9e1 100644
--- a/Lib/test/output/test_pep277
+++ b/Lib/test/output/test_pep277
@@ -1,4 +1,4 @@
test_pep277
-u'F:\\src\\python-cvs\\Lib\\test\\@test\\Gr\xfc\xdf-\u66e8\u66e9\u66eb\\\xdf-\u66e8\u66e9\u66eb'
+u'\xdf-\u66e8\u66e9\u66eb'
['???', '???', '??????', '????????????', '????G\xdf', 'Ge??-sa?', 'Gr\xfc\xdf-Gott', 'abc', 'ascii']
[u'Gr\xfc\xdf-Gott', u'abc', u'ascii', u'\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', u'\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435', u'\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', u'\u306b\u307d\u3093', u'\u66e8\u05e9\u3093\u0434\u0393\xdf', u'\u66e8\u66e9\u66eb']
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
index 480fe00..9c4aa05 100644
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -2,9 +2,7 @@
# open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
import os, unittest
from test.test_support import TESTFN, TestSkipped, TestFailed, run_suite
-try:
- from nt import _getfullpathname
-except ImportError:
+if not os.path.supports_unicode_filenames:
raise TestSkipped, "test works only on NT+"
filenames = [
@@ -24,7 +22,8 @@ def deltree(dirname):
# Don't hide legitimate errors: if one of these suckers exists, it's
# an error if we can't remove it.
if os.path.exists(dirname):
- for fname in os.listdir(dirname):
+ # must pass unicode to os.listdir() so we get back unicode results.
+ for fname in os.listdir(unicode(dirname)):
os.unlink(os.path.join(dirname, fname))
os.rmdir(dirname)
@@ -99,7 +98,7 @@ class UnicodeFileTests(unittest.TestCase):
f = open(filename, 'w')
f.write((filename + '\n').encode("utf-8"))
f.close()
- print repr(_getfullpathname(filename))
+ print repr(filename)
os.remove(filename)
os.chdir(oldwd)
os.rmdir(dirname)