New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Py_NewInterpreter() leaks a reference on warnoptions in _PySys_EndInit() #74783
Comments
Recently, the Python initialization was reworked to start to implement the PEP-432: Now, Py_NewInterpreter() leaks a reference on warnoptions in _PySys_EndInit(). We tried with Stéphane Wirtel and Louie Lu to add Py_DECREF(warnoptions), but test_capi does crash with this change. The problem is that warnoptions is stored in a C global variable *and* in sys.warnoptions of each interpreter. The ownership of this variable is unclear. I don't think that it's a good idea to share a list between two interpreters and so I created this issue to propose to redesign this variable. The tricky part is that the C global variable is also accessed by 2 public C functions: PySys_ResetWarnOptions() and PySys_AddWarnOptionUnicode(). |
I'd suggest that the right fix here would be to move warnoptions into the config struct as proposed in the PEP: https://www.python.org/dev/peps/pep-0432/#supported-configuration-settings The main reason we merged this as a private API was so we could do that setting-by-setting, with the test suite ensuring we weren't breaking anything. It looks like in this case, it's the status quo that's broken, and the change makes it possible to fix it :) |
See also bpo-30547 for other refleaks somehow related to that one. |
Nick: "I'd suggest that the right fix here would be to move warnoptions into the config struct as proposed in the PEP: https://www.python.org/dev/peps/pep-0432/#supported-configuration-settings" Nick, Eric: do you want to do that it? If you are busy, that's fine, I will just close the issue since my concern (the ref leak) is now fixed. |
We'll likely still move it eventually, but I don't think that's a good reason to keep this issue open - it's more a part of making incremental progress towards being able to make PEP-432 a public API. |
This bug came back in master: see bpo-31420. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: