diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-06-08 11:27:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-08 11:27:47 (GMT) |
commit | 865de27dd79571a4a5c7a7d22a07fb909c4a9f8e (patch) | |
tree | c2daa68764203687d70f0d15f5df2a7fb3764ac7 /Python/sysmodule.c | |
parent | ab1cb80b435a34e4f908c97cd2f3a7fe8add6505 (diff) | |
download | cpython-865de27dd79571a4a5c7a7d22a07fb909c4a9f8e.zip cpython-865de27dd79571a4a5c7a7d22a07fb909c4a9f8e.tar.gz cpython-865de27dd79571a4a5c7a7d22a07fb909c4a9f8e.tar.bz2 |
bpo-30598: _PySys_EndInit() now duplicates warnoptions (#1998)
Fix a reference in subinterpreters, like test_callbacks_leak() of
test_atexit.
warnoptions is a list used to pass options from the command line to
the sys module constructor. Before this change, the list was shared
by multiple interpreter which is not the expected behaviour. Each
interpreter should have their own independent mutable world.
This change duplicates the list in each interpreter. So each
interpreter owns its own list, so each interpreter can clear its own
list.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 7410601..424a88f 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -2136,10 +2136,10 @@ _PySys_EndInit(PyObject *sysdict) if (warnoptions == NULL) return -1; } - else { - Py_INCREF(warnoptions); - } - SET_SYS_FROM_STRING_BORROW_INT_RESULT("warnoptions", warnoptions); + + SET_SYS_FROM_STRING_INT_RESULT("warnoptions", + PyList_GetSlice(warnoptions, + 0, Py_SIZE(warnoptions))); SET_SYS_FROM_STRING_BORROW_INT_RESULT("_xoptions", get_xoptions()); |