Skip to content

Commit

Permalink
Fix message when lambda defined in interactive shell (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarovo authored and psav committed Apr 24, 2019
1 parent f487c07 commit 757fd56
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wait_for/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ def _get_context(func, message=None):
filename = f_code.co_filename
if not message:
if is_lambda_function(func):
message = 'lambda defined as `{}`'.format(inspect.getsource(func).strip())
try:
message = 'lambda defined as `{}`'.format(inspect.getsource(func).strip())
except IOError as ioerror:
# We are probably in interactive python shell or debugger,
# we cannot get source of the lambda.
message = ("lambda (Couldn't get it's source code."
"Perhaps it is defined in interactive shell.)").format(ioerror)
else:
message = "function %s()" % func.__name__
return f_code, line_no, filename, message
Expand Down

0 comments on commit 757fd56

Please sign in to comment.