mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
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.
This commit is contained in:
commit
2581bdb86a
2 changed files with 9 additions and 4 deletions
10
Lib/site.py
10
Lib/site.py
|
|
@ -598,14 +598,16 @@ def _script():
|
||||||
"""
|
"""
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
if not args:
|
if not args:
|
||||||
|
user_base = getuserbase()
|
||||||
|
user_site = getusersitepackages()
|
||||||
print("sys.path = [")
|
print("sys.path = [")
|
||||||
for dir in sys.path:
|
for dir in sys.path:
|
||||||
print(" %r," % (dir,))
|
print(" %r," % (dir,))
|
||||||
print("]")
|
print("]")
|
||||||
print("USER_BASE: %r (%s)" % (USER_BASE,
|
print("USER_BASE: %r (%s)" % (user_base,
|
||||||
"exists" if os.path.isdir(USER_BASE) else "doesn't exist"))
|
"exists" if os.path.isdir(user_base) else "doesn't exist"))
|
||||||
print("USER_SITE: %r (%s)" % (USER_SITE,
|
print("USER_SITE: %r (%s)" % (user_site,
|
||||||
"exists" if os.path.isdir(USER_SITE) else "doesn't exist"))
|
"exists" if os.path.isdir(user_site) else "doesn't exist"))
|
||||||
print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
|
print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #16804: Fix a bug in the 'site' module that caused running
|
||||||
|
'python -S -m site' to incorrectly throw an exception.
|
||||||
|
|
||||||
- Issue #15480: Remove the deprecated and unused TYPE_INT64 code from marshal.
|
- Issue #15480: Remove the deprecated and unused TYPE_INT64 code from marshal.
|
||||||
Initial patch by Daniel Riti.
|
Initial patch by Daniel Riti.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue