Message301111
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 {}
--- |
|
Date |
User |
Action |
Args |
2017-09-01 14:50:17 | vstinner | set | recipients:
+ vstinner |
2017-09-01 14:50:17 | vstinner | set | messageid: <1504277417.4.0.438645016632.issue31321@psf.upfronthosting.co.za> |
2017-09-01 14:50:17 | vstinner | link | issue31321 messages |
2017-09-01 14:50:17 | vstinner | create | |
|