mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Do not touch sys.path when site is imported and python was started with -S.
Original patch by Carl Meyer, review by Brett Cannon, small doc editions by yours truly. Fixes #11591.
This commit is contained in:
parent
f59c7b2bdd
commit
c09fca67e7
6 changed files with 36 additions and 5 deletions
10
Lib/site.py
10
Lib/site.py
|
@ -508,6 +508,11 @@ def execusercustomize():
|
|||
|
||||
|
||||
def main():
|
||||
"""Add standard site-specific directories to the module search path.
|
||||
|
||||
This function is called automatically when this module is imported,
|
||||
unless the python interpreter was started with the -S flag.
|
||||
"""
|
||||
global ENABLE_USER_SITE
|
||||
|
||||
abs_paths()
|
||||
|
@ -526,7 +531,10 @@ def main():
|
|||
if ENABLE_USER_SITE:
|
||||
execusercustomize()
|
||||
|
||||
main()
|
||||
# Prevent edition of sys.path when python was started with -S and
|
||||
# site is imported later.
|
||||
if not sys.flags.no_site:
|
||||
main()
|
||||
|
||||
def _script():
|
||||
help = """\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue