]> granicus.if.org Git - python/commitdiff
Issue #16804: Fix 'python -S -m site' failure.
authorMeador Inge <meadori@gmail.com>
Sun, 14 Apr 2013 01:29:49 +0000 (20:29 -0500)
committerMeador Inge <meadori@gmail.com>
Sun, 14 Apr 2013 01:29:49 +0000 (20:29 -0500)
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.

Lib/site.py
Misc/NEWS

index 87687e7a1b6a2edc36496c610836fee3d2158315..13e73364ae484aaf16ab5a5b8e61932b18293eae 100644 (file)
@@ -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)
 
index 7218747095a9f512ee53f89440d0c68cb1da8ebc..3187ab0f47283e3a745d5a24d1cee7b65e6b4d3e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #16804: Fix a bug in the 'site' module that caused running
+  'python -S -m site' to incorrectly throw an exception.
+
 - Issue #17016: Get rid of possible pointer wraparounds and integer overflows
   in the re module.  Patch by Nickolai Zeldovich.