Eryk Sun <eryk...@gmail.com> added the comment:
> My biggest concern with the suggested wording ... is that it > reintroduces the issue with the redirector. I thought I addressed that in second paragraph by recommending sys.executable. It could be emphasized that running "python[x][.y]" is unreliable, without going into detailed examples of where it's unreliable on various platforms (i.e. avoid going into detail about issues with naming of binaries, embedding, the search path, redirectors, etc). A separate cross-platform note in venv could advise scripts to use sys.executable, with a link to the subprocess.Popen docs and a reference to the note about the platform-dependent search behavior and unreliability of running "python[x][.y]". If the redirector issue is mentioned anywhere, I think it should be in the venv docs. It can include a note about the Windows implementation detail to use a redirector for non-symlink virtual environments. Of concern to me here is that the process handle and PID returned by CreateProcess is for the redirector. One can't use the returned process handle or PID with DuplicateHandle or WSADuplicateSocket (i.e. socket.socket.share) to share handles and sockets with a script that's running as a child process. It might seem to still be working, purely by accident, because the parent script is executing the base "python" instead of the redirector, but in that case the child script isn't using the virtual environment. There isn't an official way to support running sys._base_executable with the __PYVENV_LAUNCHER__ environment variable, as multiprocessing implements internally. Maybe the workaround should be incorporated implicitly in subprocess.Popen if `executable`, `args`, or args[0] is equa l to sys.executable and sys._base_executable is different. If the latter is implemented, and using sys.executable is strongly advised, it strengthens the case to avoid discussing the redirector entirely. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42041> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com