[New-bugs-announce] [issue42252] Embeddable Python indicates that it uses PYTHONPATH

Tom Kent report at bugs.python.org
Tue Nov 3 08:17:22 EST 2020


New submission from Tom Kent <tom at teeks99.com>:

According to the documentation https://docs.python.org/3/using/windows.html#windows-embeddable

> When extracted, the embedded distribution is (almost) fully isolated 
> from the user’s system, including environment variables, system registry 
> settings, and installed packages

The embedded distribution should ignore the environment variables. 

This is echoed in this prior issue that thought `PYTHONPATH` not being respected was a bug:
https://bugs.python.org/issue28245

Regardless of the decision to respect environment variables, the message that is displayed when running the distribution's `python --help` needs to indicate how it will act. 

Currently, for the embedded distribution, which doesn't respect the env variables, there is a section in the output from running `python -help` that indicates:

```
Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH   : ';'-separated list of directories prefixed to the
               default module search path.  The result is sys.path.
PYTHONHOME   : alternate <prefix> directory (or <prefix>;<exec_prefix>).
               The default module search path uses <prefix>\python{major}{minor}.
PYTHONPLATLIBDIR : override sys.platlibdir.
PYTHONCASEOK : ignore case in 'import' statements (Windows).
PYTHONUTF8: if set to 1, enable the UTF-8 mode.
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.
PYTHONHASHSEED: if this variable is set to 'random', a random value is used
   to seed the hashes of str and bytes objects.  It can also be set to an
   integer in the range [0,4294967295] to get hash values with a
   predictable seed.
PYTHONMALLOC: set the Python memory allocators and/or install debug hooks
   on Python memory allocators. Use PYTHONMALLOC=debug to install debug
   hooks.
PYTHONCOERCECLOCALE: if this variable is set to 0, it disables the locale
   coercion behavior. Use PYTHONCOERCECLOCALE=warn to request display of
   locale coercion and locale compatibility warnings on stderr.
PYTHONBREAKPOINT: if this variable is set to 0, it disables the default
   debugger. It can be set to the callable of your debugger of choice.
PYTHONDEVMODE: enable the development mode.
PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.
```

This may lead users (it did lead this one) to assume that they are doing something wrong when for example the output of `sys.path` doesn't included items in `os.environ["PYTHONPATH"]`. 

Realizing that it may be difficult to achieve, the help output should match the state of what the interpreter will actually do if run.

----------
components: Windows
messages: 380274
nosy: paul.moore, steve.dower, teeks99, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Embeddable Python indicates that it uses PYTHONPATH
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42252>
_______________________________________


More information about the New-bugs-announce mailing list