[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-22 Thread STINNER Victor


STINNER Victor  added the comment:

I has been decided to not backport the change to Python 3.7: see PR 10532 
discusssion.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a5194115733f6ca8fc1ddbee43eabbde536900e6 by Victor Stinner in 
branch '3.7':
Revert "bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)" 
(GH-10660)
https://github.com/python/cpython/commit/a5194115733f6ca8fc1ddbee43eabbde536900e6


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +9913

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-16 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-16 Thread miss-islington


miss-islington  added the comment:


New changeset d2be9a5c13221fb84c2221bbfd93efac6111e697 by Miss Islington (bot) 
in branch '3.7':
bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)
https://github.com/python/cpython/commit/d2be9a5c13221fb84c2221bbfd93efac6111e697


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9815

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-16 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 37cd982df02795905886ab36a2378ed557cb6f60 by Victor Stinner in 
branch 'master':
bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)
https://github.com/python/cpython/commit/37cd982df02795905886ab36a2378ed557cb6f60


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-14 Thread STINNER Victor


STINNER Victor  added the comment:

Python has 3 kind of configurations:

* global configuration variables like Py_VerboseFlag
* core configuration: _PyCoreConfig
* main interpreter configuration: _PyMainInterpreterConfig

I tried to keep them consistency. Yesterday, I rewrote 
test_embed.InitConfigTests to really test that these 3 configurations are 
consistent... And I found multiple bugs :-) (I fixed them as well)

sys.flags is immutable, but some configurations are only used to "initialize" 
Python which can then be modified. sys.path is a good example.

I don't think that we can ensure that sys.path is always consistent with the 
main/core configuration (module_search_paths). It's possible to write "sys.path 
= ['/new/path']". There is no machinery at the module level to call a function 
when a sys module is *replaced*.

I propose to try to ensure that the configuration is not modified during Python 
lifecycle, and so that sys.path is a *copy* of the configuration. Same 
rationale for sys.warnoptions (list) and sys._xoptions (dict).

Attached PR 10532 implements this solution: copy lists and dicts.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-13 Thread STINNER Victor


STINNER Victor  added the comment:

Attached PR 10532 modifies _PySys_EndInit() to copy lists and dictionaries from 
the config.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-13 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +9786
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35239] _PySys_EndInit() doesn't copy main interpreter configuration

2018-11-13 Thread STINNER Victor


New submission from STINNER Victor :

Extract of _PySys_EndInit():

SET_SYS_FROM_STRING_BORROW("path", config->module_search_path);

sys.path is initialized from _PyMainInterpreterConfig.module_search_path 
object: the list of strings is not copied. As a consequence, when sys.path is 
modified, _PyMainInterpreterConfig is modified as well. For example, "import 
site" modifies sys.path.

I dislike this behavior. I prefer to see _PyMainInterpreterConfig as 
"constant": a snapshot of the configuration used to startup Python.

A side effect is that Py_NewInterpreter() copies the modified configuration, 
whereas starting from the "original" configuration. For the specific case of 
Py_NewInterpreter(), I'm not sure of what is the expected behavior... 
Py_NewInterpreter() imports the "site" module again, so it should reapply the 
same sys.path change.

Note: I found this bug while working on better tests for global, core and main 
configurations: https://github.com/python/cpython/pull/10524

--
components: Interpreter Core
messages: 329872
nosy: eric.snow, ncoghlan, vstinner
priority: normal
severity: normal
status: open
title: _PySys_EndInit() doesn't copy main interpreter configuration
versions: Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com