From 5edb30e97e28ebaa69d1c03d34d64d550551414d Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Fri, 16 Apr 2021 19:26:17 +0400 Subject: [PATCH] fix: handle StopIteration --- brownie/network/transaction.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index 0f61acde2..16d2f947b 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -716,8 +716,8 @@ def _reverted_trace(self, trace: Sequence,) -> None: self._dev_revert_msg = "" return - step = next(i for i in trace[::-1] if i["op"] in ("REVERT", "INVALID")) - self._revert_msg = "invalid opcode" if step["op"] == "INVALID" else "" + op = next((i["op"] for i in trace[::-1] if i["op"] in ("REVERT", "INVALID")), None) + self._revert_msg = "invalid opcode" if op == "INVALID" else "" def _expand_trace(self) -> None: """Adds the following attributes to each step of the stack trace: @@ -1101,7 +1101,10 @@ def _traceback_string(self) -> str: except StopIteration: return "" - result = [next(i for i in trace_range if trace[i]["source"])] + try: + result = [next(i for i in trace_range if trace[i]["source"])] + except StopIteration: + return "" depth, jump_depth = trace[idx]["depth"], trace[idx]["jumpDepth"] while True: