classification
Title: remove_module() needs to save/restore exception state
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 3.8, Python 3.7, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, brett.cannon, eric.snow, herring, ncoghlan
Priority: normal Keywords: patch

Created on 2015-04-24 05:58 by herring, last changed 2019-05-14 04:34 by ZackerySpytz.

Pull Requests
URL Status Linked Edit
PR 13005 merged ZackerySpytz, 2019-04-29 09:29
Messages (5)
msg241914 - (view) Author: Davis Herring (herring) Date: 2015-04-24 05:58
import.c's remove_module() is always called with an exception set and can invoke arbitrary code via deallocation; if that code calls PyErr_Clear() (or is sensitive to PyErr_Occurred()) it will lose (or be damaged by) the preexisting exception.
msg341063 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-04-29 09:30
I've created a PR for this issue.
msg341905 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2019-05-08 16:31
New changeset 94a64e9cd411a87514b68082c1c437eb3b49dfb9 by Nick Coghlan (Zackery Spytz) in branch 'master':
bpo-24048: Save the live exception during import.c's remove_module() (GH-13005)
https://github.com/python/cpython/commit/94a64e9cd411a87514b68082c1c437eb3b49dfb9
msg342428 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-05-14 04:16
Can this be closed, Nick?
msg342430 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-05-14 04:34
I think this change should be backported.
History
Date User Action Args
2019-05-14 04:34:31ZackerySpytzsetmessages: + msg342430
2019-05-14 04:16:07brett.cannonsetmessages: + msg342428
2019-05-08 16:31:28ncoghlansetmessages: + msg341905
2019-04-29 09:30:49ZackerySpytzsetnosy: + ZackerySpytz

messages: + msg341063
versions: + Python 3.7, Python 3.8, - Python 3.2, Python 3.3, Python 3.4, Python 3.5
2019-04-29 09:29:55ZackerySpytzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12926
2015-04-24 14:39:35brett.cannonsetnosy: + brett.cannon, ncoghlan, eric.snow
2015-04-24 05:58:38herringcreate