Skip to content

Commit 23cd52c

Browse files
committed
clear up crufty old __return__ values
1 parent 219ee06 commit 23cd52c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎v3/pg_logger.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ def user_return(self, frame, return_value):
254254
"""This function is called when a return trap is set here."""
255255
frame.f_locals['__return__'] = return_value
256256
self.interaction(frame, None, 'return')
257+
# delete __return__ so that on subsequent calls to
258+
# a generator function, the OLD yielded (returned)
259+
# value gets deleted from the frame ...
260+
# (this also clears away crufty obsolete return values in other
261+
# kinds of examples as well, most notably those involving closures)
262+
del frame.f_locals['__return__']
257263

258264
def user_exception(self, frame, exc_info):
259265
exc_type, exc_value, exc_traceback = exc_info

0 commit comments

Comments
 (0)