diff --git a/src/ape/exceptions.py b/src/ape/exceptions.py index 75fb039338..45286d9c18 100644 --- a/src/ape/exceptions.py +++ b/src/ape/exceptions.py @@ -693,7 +693,10 @@ def _get_custom_python_traceback( continue depth = exec_item.depth - lineno = exec_item.begin_lineno + + # NOTE: Use the last lineno executed as "the line number". + lineno = exec_item.begin_lineno if exec_item.end_lineno is None else exec_item.end_lineno + if lineno is None: idx -= 1 continue diff --git a/src/ape/types/__init__.py b/src/ape/types/__init__.py index 42c736e72f..647dd7d20e 100644 --- a/src/ape/types/__init__.py +++ b/src/ape/types/__init__.py @@ -164,10 +164,10 @@ def from_event( from ape import convert from ape.utils.abi import LogInputABICollection, is_dynamic_sized_type - event = getattr(event, "abi", event) + event_abi: EventABI = getattr(event, "abi", event) # type: ignore[assignment] search_topics = search_topics or {} - topic_filter: List[Optional[HexStr]] = [encode_hex(keccak(text=event.selector))] - abi_inputs = LogInputABICollection(event) + topic_filter: List[Optional[HexStr]] = [encode_hex(keccak(text=event_abi.selector))] + abi_inputs = LogInputABICollection(event_abi) def encode_topic_value(abi_type, value): if isinstance(value, (list, tuple)): @@ -190,7 +190,7 @@ def encode_topic_value(abi_type, value): invalid_topics = set(search_topics) - set(topic_names) if invalid_topics: raise ValueError( - f"{event.name} defines {', '.join(topic_names)} as indexed topics, " + f"{event_abi.name} defines {', '.join(topic_names)} as indexed topics, " f"but you provided {', '.join(invalid_topics)}" ) @@ -200,7 +200,7 @@ def encode_topic_value(abi_type, value): return cls( addresses=addresses or [], - events=[event], + events=[event_abi], topic_filter=topic_filter, start_block=start_block, stop_block=stop_block,