You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better error handling in PyImport_Cleanup() #77511
The proposed PR adds missed checks for errors and PyErr_Clear() calls in PyImport_Cleanup().
It may be worth to use PyErr_WriteUnraisable() in place of PyErr_Clear() (newly added and existing) in most cases. But this can add an unexpected noise, and I don't wont to do this at this stage of 3.7. It could be done in 3.8 though, and backported to 3.7 later.
I'm not sure that PyImport_Cleanup() works properly if sys.modules is not a dict. At this stage a custom mapping will likely be broken when most of modules are destroyed.
PR 6606 replaces PyErr_Clear() with PyErr_WriteUnraisable(). This may add an unexpected noise at shutdown' but on other hand, this may be a helpful information in the case if something wrong happen. It doesn't produce additional output when run all tests, this means that that all is successful. I wonder in which circumstance that output will be occurred.
See also bpo-33379 about the bug in subinterpreters exposed when add yet one PyErr_WriteUnraisable() in PyImport_Cleanup() (it was not added because of this).
Activity
serhiy-storchaka commentedon Apr 22, 2018
The proposed PR adds missed checks for errors and PyErr_Clear() calls in PyImport_Cleanup().
It may be worth to use PyErr_WriteUnraisable() in place of PyErr_Clear() (newly added and existing) in most cases. But this can add an unexpected noise, and I don't wont to do this at this stage of 3.7. It could be done in 3.8 though, and backported to 3.7 later.
I'm not sure that PyImport_Cleanup() works properly if sys.modules is not a dict. At this stage a custom mapping will likely be broken when most of modules are destroyed.
serhiy-storchaka commentedon Apr 25, 2018
New changeset e9d9494 by Serhiy Storchaka in branch 'master':
bpo-33330: Improve error handling in PyImport_Cleanup(). (GH-6564)
e9d9494
miss-islington commentedon Apr 25, 2018
New changeset 291c9d4 by Miss Islington (bot) in branch '3.7':
bpo-33330: Improve error handling in PyImport_Cleanup(). (GH-6564)
291c9d4
serhiy-storchaka commentedon Apr 25, 2018
PR 6606 replaces PyErr_Clear() with PyErr_WriteUnraisable(). This may add an unexpected noise at shutdown' but on other hand, this may be a helpful information in the case if something wrong happen. It doesn't produce additional output when run all tests, this means that that all is successful. I wonder in which circumstance that output will be occurred.
serhiy-storchaka commentedon Apr 26, 2018
New changeset b16681f by Serhiy Storchaka in branch '3.6':
[3.6] bpo-33330: Improve error handling in PyImport_Cleanup(). (GH-6564). (GH-6604)
b16681f
serhiy-storchaka commentedon Apr 26, 2018
New changeset 55299ff by Serhiy Storchaka in branch '2.7':
[2.7] bpo-33330: Improve error handling in PyImport_Cleanup(). (GH-6564). (GH-6605)
55299ff
serhiy-storchaka commentedon Apr 29, 2018
New changeset c1a6832 by Serhiy Storchaka in branch 'master':
bpo-33330: Write exceptions occurred in PyImport_Cleanup() to stderr. (GH-6606)
c1a6832
vstinner commentedon May 23, 2018
I reopen the issue because I created the PR 7068 to propose further checks (in debug mode).
serhiy-storchaka commentedon May 23, 2018
See also bpo-33379 about the bug in subinterpreters exposed when add yet one PyErr_WriteUnraisable() in PyImport_Cleanup() (it was not added because of this).
iritkatriel commentedon Jun 20, 2022
Is there anything left to do here?
vstinner commentedon Jun 21, 2022
I gave up on my further enhancements #7068 (comment), so I just close the issue.