]> granicus.if.org Git - python/commitdiff
bpo-29592: site: skip abs_paths() when it's redundant (GH-167)
authorINADA Naoki <methane@users.noreply.github.com>
Tue, 14 Mar 2017 15:52:19 +0000 (00:52 +0900)
committerGitHub <noreply@github.com>
Tue, 14 Mar 2017 15:52:19 +0000 (00:52 +0900)
Call abs_paths() only if removeduppaths() changed sys.path

Lib/site.py

index 0fc92009e19af36eefd5925713a4d690fb26db5e..4f96ca91170c54c8bce0f461477d857be174f028 100644 (file)
@@ -522,8 +522,13 @@ def main():
     """
     global ENABLE_USER_SITE
 
-    abs_paths()
+    orig_path = sys.path[:]
     known_paths = removeduppaths()
+    if orig_path != sys.path:
+        # removeduppaths() might make sys.path absolute.
+        # fix __file__ and __cached__ of already imported modules too.
+        abs_paths()
+
     known_paths = venv(known_paths)
     if ENABLE_USER_SITE is None:
         ENABLE_USER_SITE = check_enableusersite()