[New-bugs-announce] [issue11591] "python -S" should be robust against e.g. "from site import addsitedir"

Carl Meyer report at bugs.python.org
Thu Mar 17 20:47:00 CET 2011

New submission from Carl Meyer <carl at dirtcircle.com>:

If python is run with the -S flag, that declares the intent of the user to not have site-specific additions to sys.path.

However, some code in that process may have a legitimate need for a function defined in site.py - for instance, addsitedir. But the act of importing site.py, as a side effect, adds the standard site-specific directories to sys.path.

python -S would be more useful and reliable if it prevented importing site from automatically making the sys.path additions. There is no loss of flexibility here, as user code could still explicitly call site.main() to achieve all of the current side-effects of "import site".

The fix is a one-liner, and is in the linked hg repository.

components: Library (Lib)
hgrepos: 4
messages: 131281
nosy: carljm
priority: normal
severity: normal
status: open
title: "python -S" should be robust against e.g. "from site import addsitedir"
type: behavior

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list