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.
Created on 2017年09月01日 14:50 by vstinner, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| clear_frames_bug.py | vstinner, 2017年09月01日 14:54 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 3262 | closed | vstinner, 2017年09月01日 14:51 | |
| Messages (4) | |||
|---|---|---|---|
| msg301111 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月01日 14:50 | |
traceback.clear_frames(): "Clears the local variables of all the stack frames in a traceback tb by calling the clear() method of each frame object." https://docs.python.org/dev/library/traceback.html#traceback.clear_frames That's wrong: it only calls frame.clear() on the top frame of each traceback object. Output of attached clear_frames_bug.py script: --- locals: frame locals {'z': 3} frame locals {'y': 2} frame locals {'x': 1} clear_frames() locals: frame locals {} frame locals {'y': 2} frame locals {'x': 1} --- As you can see, only the locals of the func3() frame, where the exception was raised, is clear. Locals of other frames are not cleared. Attached PR fixes the issue. Output with the fix: --- locals: frame locals {'z': 3} frame locals {'y': 2} frame locals {'x': 1} clear_frames() locals: frame locals {} frame locals {} frame locals {} --- |
|||
| msg301113 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月01日 14:52 | |
Would it be ok to backport such change to Python 3.6? It's a bugfix, no? |
|||
| msg301114 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月01日 14:53 | |
traceback.clear_frames() was added by bpo-1565525: commit 173a157e725579eec1f28f8c9d53d6761ba6c79f. |
|||
| msg301117 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年09月01日 14:59 | |
See bpo-31323 where I wanted to use traceback.clear_frames() to manually break a reference cycle. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:51 | admin | set | github: 75502 |
| 2018年09月19日 23:09:12 | vstinner | set | status: open -> closed resolution: out of date stage: resolved |
| 2017年09月01日 14:59:45 | vstinner | set | messages: + msg301117 |
| 2017年09月01日 14:54:31 | vstinner | set | versions: + Python 3.6 |
| 2017年09月01日 14:54:07 | vstinner | set | files: + clear_frames_bug.py |
| 2017年09月01日 14:53:07 | vstinner | set | messages: + msg301114 |
| 2017年09月01日 14:52:12 | vstinner | set | messages: + msg301113 |
| 2017年09月01日 14:51:21 | vstinner | set | pull_requests: + pull_request3305 |
| 2017年09月01日 14:50:17 | vstinner | create | |