Since I didn't get any serious review on my pull request since
February, I created this thread on python-dev to get more people
looking into this issue.

On Wed, Apr 27, 2022 at 5:30 PM Paul Moore <p.f.mo...@gmail.com> wrote:
>
> On Wed, 27 Apr 2022 at 15:32, Victor Stinner <vstin...@python.org> wrote:
> >
> > On Tue, Apr 26, 2022 at 11:46 AM Victor Stinner <vstin...@python.org> wrote:
> > > I propose adding a -P option to Python command line interface to "not
> > > add sys.path[0]":
> > > https://github.com/python/cpython/pull/31542
> >
> > My plan is to merge this change at 2022-05-05, the day before the
> > Python 3.11 feature freeze,
>
> Why leave it until the last minute? That just makes it harder to
> revert if someone immediately finds a problem with it.

I wrote my PR in February. If it goes wrong, we will have until
October to revert it. The idea is to merge it before beta1 to have 6
months to play with it and check for corner cases.


> It seems very rushed to propose this and implement it days before 3.11
> freeze. If it's been an issue for 11 years, then (a) why didn't anyone
> propose this solution months ago, and (b) surely it can wait another
> year?

Different solutions were proposed over the last 11 years. See for
example: https://bugs.python.org/issue13475

Sadly, no solution was merged into Python, only discussed.


> Steve Dower mentioned some (IMO)
> reasonable points, and you pretty much dismissed them without any
> discussion. That doesn't seem like the right way to handle this. In
> particular, I think the question of how this flag interacts with all
> the other flags and settings that affect sys.path and how "isolated"
> Python is, is an important thing to consider[^1].

See the init_config.rst documentation of my PR: isolated=1 implies
add_path=0 (no behavior change)
https://github.com/python/cpython/pull/31542/files

Running Python with a ._pth file implies isolated=1 and so add_path=0
(no behavior change).

It seems like Steve's proposal is orthogonal, but I don't think that
it's exclusive. We can add a second option, no?


> [^1]: We've had multiple attempts to get locale and UTF8 handling
> right, and now have a mess of flags, environment variables, and
> options that frankly only the experts can understand. I fear that we
> could end up with the same issue for "Python initialisation flags" if
> we don't take a less rushed approach.

The locale encoding, the Python filesystem encoding and the Python
UTF-8 Mode are way more complicated problems. I spent years to fix
issues about these, so I'm well aware of these issue. By the way, I
also designed PEP 587 PyConfig API and I implemented it.

Here the -P option effect is restricted to a single function:
pymain_run_python(). My pull request can be summarized as:

- else if (!config->isolated) {
+ else if (config->add_path0) {

Do you think that we should pay attention to something in specific?
Right now, I propose to not add an environment variable and -P is
unrelated to -E (ignore env vars).

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BFZIGOIVCBNSHBQS7JHKXWWYTENGUWJO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to