Skip to content

Commit 2e158d9

Browse files
author
Philip Guo
committed
keep return values around for zombie frames but NOT for subsequent generator calls
1 parent 048c69a commit 2e158d9

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎v3/pg_logger.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ def user_call(self, frame, argument_list):
239239
if self._wait_for_mainpyfile:
240240
return
241241
if self.stop_here(frame):
242+
# delete __return__ so that on subsequent calls to
243+
# a generator function, the OLD yielded (returned)
244+
# value gets deleted from the frame ...
245+
try:
246+
del frame.f_locals['__return__']
247+
except KeyError:
248+
pass
249+
242250
self.interaction(frame, None, 'call')
243251

244252
def user_line(self, frame):
@@ -254,12 +262,6 @@ def user_return(self, frame, return_value):
254262
"""This function is called when a return trap is set here."""
255263
frame.f_locals['__return__'] = return_value
256264
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__']
263265

264266
def user_exception(self, frame, exc_info):
265267
exc_type, exc_value, exc_traceback = exc_info

0 commit comments

Comments
 (0)