summaryrefslogtreecommitdiff
path: root/Lib/site.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-03-23 02:06:24 +0100
committerÉric Araujo <merwok@netwok.org>2011-03-23 02:06:24 +0100
commit0621adfa9ac55fc6a9a7bf0a73b8516416162da1 (patch)
tree97c216592a52a4b6d35e07851639113e76c2ee7d /Lib/site.py
parentcd816cd91e144b4ee99d1bdcd8d4011cfa9e0a5e (diff)
downloadcpython-0621adfa9ac55fc6a9a7bf0a73b8516416162da1.tar.gz
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.
Diffstat (limited to 'Lib/site.py')
-rw-r--r--Lib/site.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/site.py b/Lib/site.py
index a2c0becbc1..fcfdbedf26 100644
--- a/Lib/site.py
+++ b/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 = """\