Skip to content

Commit

Permalink
Merge pull request #16 from emundo/fixes
Browse files Browse the repository at this point in the history
Fixes AttributeError popup on Filter
  • Loading branch information
akorb authored Dec 10, 2020
2 parents 5ed20f4 + 15ae023 commit c76b535
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/scapy-packet_viewer.svg)](https://pypi.org/project/scapy-packet_viewer/)
[![Documentation Status](https://readthedocs.org/projects/scapy-packet_viewer/badge/?version=latest)](https://scapy-packet_viewer.readthedocs.io/en/latest/?badge=latest)

TODO: non-Travis build status

# scapy-packet_viewer #

Packet viewer for SecDev's [Scapy](https://scapy.net/).
Expand Down
15 changes: 12 additions & 3 deletions scapy_packet_viewer/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,24 @@ def filter_changed(self, new_filter):
for checkbox in self.packet_view.body:
checkbox.base_widget.state = False
return


attribute_error_count = 0
last_exception = None
try:
compiled_code = compile(new_filter, filename="", mode="eval")
for checkbox in self.packet_view.body:
p = checkbox.base_widget.tag
# See text_to_packet() for some explanations
global_scope = {"p": p, "__builtins__": {"len": len}}
matches = bool(eval(compiled_code, global_scope)) # pylint: disable=eval-used
checkbox.base_widget.state = matches
try:
matches = bool(eval(compiled_code, global_scope)) # pylint: disable=eval-used
checkbox.base_widget.state = matches
except AttributeError as e:
attribute_error_count += 1
last_exception = e
# Suppress attribute errors, if they don't apply for all packets in packet_view.body
if len(self.packet_view.body) == attribute_error_count:
raise last_exception
except NameError:
self._emit(
"info_popup",
Expand Down

0 comments on commit c76b535

Please sign in to comment.