This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2015-04-24 05:58 by herring, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13005 merged ZackerySpytz, 2019-04-29 09:29
PR 20521 merged miss-islington, 2020-05-29 19:17
Messages (9)
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.
msg370329 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2020-05-29 17:48
Assigning to Nick to decide if he wants to backport it to 3.7 before it's no longer possible.
msg370335 - (view) Author: miss-islington (miss-islington) Date: 2020-05-29 19:35
New changeset 5aa40e587e63bcad22c7e196fc3559e2b5e0792b by Miss Islington (bot) in branch '3.7':
bpo-24048: Save the live exception during import.c's remove_module() (GH-13005)
https://github.com/python/cpython/commit/5aa40e587e63bcad22c7e196fc3559e2b5e0792b
msg370497 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2020-05-31 18:47
It seems that Serhiy backported the fix.
msg372498 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2020-06-28 06:52
Belatedly marking this as resolved.
History
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68236
2020-06-28 06:52:49ncoghlansetstatus: open -> closed
resolution: fixed
messages: + msg372498

stage: patch review -> resolved
2020-05-31 18:47:10ZackerySpytzsetmessages: + msg370497
2020-05-29 19:35:28miss-islingtonsetmessages: + msg370335
2020-05-29 19:17:32miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request19765
2020-05-29 17:49:12brett.cannonsetnosy: - brett.cannon
2020-05-29 17:48:58brett.cannonsetassignee: ncoghlan
messages: + msg370329
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