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: Globals (and presumably builtins) are cleared premuturely in FrameObject
Type: behavior Stage: resolved
Components: Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Mark.Shannon, vstinner
Priority: normal Keywords: patch

Created on 2021-06-17 11:14 by Mark.Shannon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26768 merged Mark.Shannon, 2021-06-17 11:41
Messages (6)
msg395995 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-06-17 11:14
When calling frame.clear(), the globals (and builtins) are cleared.
This is not the case in 3.10. We should restore the 3.10 behavior, as there is no reason not to.


Victor, you've mentioned this problem. Did you have a specific example I can add as a test?
msg396002 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-17 14:18
> Victor, you've mentioned this problem. Did you have a specific example I can add as a test?

Sorry, I didn't have any reproducer. I vaguely recall an error in the unittest module when getting globals from a frame.
msg396008 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-06-17 15:40
No problem, I've added a simple test.
msg396259 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-21 15:46
See also bpo-44288: can it be a duplicate?
msg396261 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-21 15:47
The bpo number is missing from the merged commit, it's:

commit ba2f32a983a08c4f64c23c187432e38908639c12
Author: Mark Shannon <mark@hotpy.org>
Date:   Thu Jun 17 16:29:15 2021 +0100

    Do not clear globals or builtins when calling clear() on a frame object. Reverts behavior to that of 3.10 and earlier. (GH-26768)
msg396692 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-29 01:37
I marked bpo-44288 as a duplicate of this issue.
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88608
2021-06-29 01:37:35vstinnersetmessages: + msg396692
2021-06-29 01:37:20vstinnerlinkissue44288 superseder
2021-06-21 15:47:25vstinnersetmessages: + msg396261
2021-06-21 15:46:08vstinnersetmessages: + msg396259
2021-06-17 15:40:11Mark.Shannonsetstatus: open -> closed
resolution: fixed
stage: resolved
2021-06-17 15:40:00Mark.Shannonsetmessages: + msg396008
stage: patch review -> (no value)
2021-06-17 14:18:19vstinnersetmessages: + msg396002
2021-06-17 11:41:18Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request25355
2021-06-17 11:14:29Mark.Shannoncreate