python

changeset 45031:77f3ad10ba45 trunk

Fix issue6612: 'import site' fails when called from an unlinked directory
author W. Trevor King <wking@drexel.edu>
date Thu Jul 29 17:06:29 2010 -0400 (22 months ago)
parents d2c464d2ee82
children
files Lib/site.py Lib/sysconfig.py
line diff
     1.1 --- a/Lib/site.py	Sat Jul 03 15:57:30 2010 +0200
     1.2 +++ b/Lib/site.py	Thu Jul 29 17:06:29 2010 -0400
     1.3 @@ -102,7 +102,10 @@
     1.4          # Filter out duplicate paths (on case-insensitive file systems also
     1.5          # if they only differ in case); turn relative paths into absolute
     1.6          # paths.
     1.7 -        dir, dircase = makepath(dir)
     1.8 +        try:
     1.9 +            dir, dircase = makepath(dir)
    1.10 +        except os.error:
    1.11 +            continue
    1.12          if not dircase in known_paths:
    1.13              L.append(dir)
    1.14              known_paths.add(dircase)
     2.1 --- a/Lib/sysconfig.py	Sat Jul 03 15:57:30 2010 +0200
     2.2 +++ b/Lib/sysconfig.py	Thu Jul 29 17:06:29 2010 -0400
     2.3 @@ -434,8 +434,12 @@
     2.4          # from a different directory.
     2.5          if _PYTHON_BUILD and os.name == "posix":
     2.6              base = _PROJECT_BASE
     2.7 +            try:
     2.8 +                cwd = os.getcwd()
     2.9 +            except os.error:
    2.10 +                cwd = None
    2.11              if (not os.path.isabs(_CONFIG_VARS['srcdir']) and
    2.12 -                base != os.getcwd()):
    2.13 +                base != cwd):
    2.14                  # srcdir is relative and we are not in the same directory
    2.15                  # as the executable. Assume executable is in the build
    2.16                  # directory and make srcdir absolute.