Skip to content

Commit

Permalink
Don't return early when "returning" from a module
Browse files Browse the repository at this point in the history
We still need to run interaction so that the debugger will show the result of
the last line that was run. We just don't want it to treat the end of the
module as a "return".

For instance, if you have a file with a single variable definition

    a = 1

then if you stop on the definition, pudb will show the variable "a: 1" in the
variables view (but it won't show "return: None" after stepping again).

Fixes #264 (comment).
  • Loading branch information
asmeurer committed Sep 3, 2017
1 parent 6be804e commit 6e285b6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pudb/debugger.py
Expand Up @@ -382,10 +382,8 @@ def user_line(self, frame):

def user_return(self, frame, return_value):
"""This function is called when a return trap is set here."""
if frame.f_code.co_name == '<module>':
return

frame.f_locals['__return__'] = return_value
if frame.f_code.co_name != '<module>':
frame.f_locals['__return__'] = return_value

if self._wait_for_mainpyfile:
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
Expand Down

0 comments on commit 6e285b6

Please sign in to comment.