Skip to content

Commit 2e4e011

Browse files
authored
bpo-29592: site: skip abs_paths() when it's redundant (GH-167)
Call abs_paths() only if removeduppaths() changed sys.path
1 parent aa289a5 commit 2e4e011

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/site.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,13 @@ def main():
522522
"""
523523
global ENABLE_USER_SITE
524524

525-
abs_paths()
525+
orig_path = sys.path[:]
526526
known_paths = removeduppaths()
527+
if orig_path != sys.path:
528+
# removeduppaths() might make sys.path absolute.
529+
# fix __file__ and __cached__ of already imported modules too.
530+
abs_paths()
531+
527532
known_paths = venv(known_paths)
528533
if ENABLE_USER_SITE is None:
529534
ENABLE_USER_SITE = check_enableusersite()

0 commit comments

Comments
 (0)