Skip to content

Commit

Permalink
bpo-30598: _PySys_EndInit() now duplicates warnoptions (#1998)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vstinner authored Jun 8, 2017
1 parent ab1cb80 commit 865de27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 865de27

Please sign in to comment.