Skip to content

Commit d877990

Browse files
Hide ValueErrors in Packet.setfieldval() optimization (#4705)
1 parent d64e574 commit d877990

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

scapy/packet.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ def setfieldval(self, attr, val):
667667
# Let the execution go on, especially on the payload.
668668
# An `AttributeError` may eventually be raised in case of a `NoPayload`.
669669
pass
670+
except ValueError:
671+
# Value comparisons may fail (may occur with `FlagValue`s among other).
672+
# Forget the optimization in such case.
673+
pass
670674

671675
if self.deprecated_fields and attr in self.deprecated_fields:
672676
attr = self._resolve_alias(attr)

0 commit comments

Comments
 (0)