summaryrefslogtreecommitdiffstats
path: root/Lib/site.py
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2013-04-14 01:29:49 (GMT)
committerMeador Inge <meadori@gmail.com>2013-04-14 01:29:49 (GMT)
commit9a7a81195ce42efc92fac04c19a2fe9f0562ef51 (patch)
tree06d534e2310a7b5430d22e0f8344d21770763e01 /Lib/site.py
parent0bfd6acf03640f8910b8f9fa10cc7775a7c55449 (diff)
downloadcpython-9a7a81195ce42efc92fac04c19a2fe9f0562ef51.zip
cpython-9a7a81195ce42efc92fac04c19a2fe9f0562ef51.tar.gz
cpython-9a7a81195ce42efc92fac04c19a2fe9f0562ef51.tar.bz2
Issue #16804: Fix 'python -S -m site' failure.
This commit fixes a bug in the 'site' module that was causing an exception to incorrectly be thrown when running 'python -S -m site'. The problem was that 'USER_BASE' and 'USER_SITE' were being accessed before they were properly initialized. The code has been changed to use 'getuserbase' and 'getusersitepackages' instead so that the initialization always happens.
Diffstat (limited to 'Lib/site.py')
-rw-r--r--Lib/site.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/site.py b/Lib/site.py
index 87687e7..13e7336 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -620,14 +620,16 @@ def _script():
"""
args = sys.argv[1:]
if not args:
+ user_base = getuserbase()
+ user_site = getusersitepackages()
print("sys.path = [")
for dir in sys.path:
print(" %r," % (dir,))
print("]")
- print("USER_BASE: %r (%s)" % (USER_BASE,
- "exists" if os.path.isdir(USER_BASE) else "doesn't exist"))
- print("USER_SITE: %r (%s)" % (USER_SITE,
- "exists" if os.path.isdir(USER_SITE) else "doesn't exist"))
+ print("USER_BASE: %r (%s)" % (user_base,
+ "exists" if os.path.isdir(user_base) else "doesn't exist"))
+ print("USER_SITE: %r (%s)" % (user_site,
+ "exists" if os.path.isdir(user_site) else "doesn't exist"))
print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
sys.exit(0)