diff options
author | Fred Drake <fdrake@acm.org> | 2001-07-02 16:55:42 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-07-02 16:55:42 (GMT) |
commit | 1fb5ce0323926406e6b3db6879152e0dcc40f5ec (patch) | |
tree | 594f1e6ab06e625b74baad39a4914501dde07433 | |
parent | b0f05bdfd367a6bbcc1d47c3daa3359e7308e7b9 (diff) | |
download | cpython-1fb5ce0323926406e6b3db6879152e0dcc40f5ec.zip cpython-1fb5ce0323926406e6b3db6879152e0dcc40f5ec.tar.gz cpython-1fb5ce0323926406e6b3db6879152e0dcc40f5ec.tar.bz2 |
Avoid using os.path.normcase() on sys.path elements; doing so causes paths
to be presented in an unfamiliar case on case-preserving filesystems.
This closes SF patch #436173.
-rw-r--r-- | Lib/site.py | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/Lib/site.py b/Lib/site.py index b8174f9..5d2e9ed 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -66,22 +66,23 @@ else: def makepath(*paths): - dir = os.path.join(*paths) - return os.path.normcase(os.path.abspath(dir)) + dir = os.path.abspath(os.path.join(*paths)) + return dir, os.path.normcase(dir) -L = sys.modules.values() -for m in L: +for m in sys.modules.values(): if hasattr(m, "__file__") and m.__file__: - m.__file__ = makepath(m.__file__) -del m, L + m.__file__ = os.path.abspath(m.__file__) +del m # This ensures that the initial path provided by the interpreter contains # only absolute pathnames, even if we're running from the build directory. L = [] +dirs_in_sys_path = {} for dir in sys.path: - dir = makepath(dir) - if dir not in L: + dir, dircase = makepath(dir) + if not dirs_in_sys_path.has_key(dircase): L.append(dir) + dirs_in_sys_path[dircase] = 1 sys.path[:] = L del dir, L @@ -95,14 +96,13 @@ if os.name == "posix" and os.path.basename(sys.path[-1]) == "Modules": del get_platform, s def addsitedir(sitedir): - sitedir = makepath(sitedir) - if sitedir not in sys.path: + sitedir, sitedircase = makepath(sitedir) + if not dirs_in_sys_path.has_key(sitedircase): sys.path.append(sitedir) # Add path component try: names = os.listdir(sitedir) except os.error: return - names = map(os.path.normcase, names) names.sort() for name in names: if name[-4:] == endsep + "pth": @@ -125,9 +125,10 @@ def addpackage(sitedir, name): continue if dir[-1] == '\n': dir = dir[:-1] - dir = makepath(sitedir, dir) - if dir not in sys.path and os.path.exists(dir): + dir, dircase = makepath(sitedir, dir) + if not dirs_in_sys_path.has_key(dircase) and os.path.exists(dir): sys.path.append(dir) + dirs_in_sys_path[dircase] = 1 prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: @@ -135,19 +136,21 @@ if sys.exec_prefix != sys.prefix: for prefix in prefixes: if prefix: if os.sep == '/': - sitedirs = [makepath(prefix, - "lib", - "python" + sys.version[:3], - "site-packages"), - makepath(prefix, "lib", "site-python")] + sitedirs = [os.path.join(prefix, + "lib", + "python" + sys.version[:3], + "site-packages"), + os.path.join(prefix, "lib", "site-python")] elif os.sep == ':': - sitedirs = [makepath(prefix, "lib", "site-packages")] + sitedirs = [os.path.join(prefix, "lib", "site-packages")] else: sitedirs = [prefix] for sitedir in sitedirs: if os.path.isdir(sitedir): addsitedir(sitedir) +del dirs_in_sys_path + # Define new built-ins 'quit' and 'exit'. # These are simply strings that display a hint on how to exit. if os.sep == ':': |