Skip to content
Snippets Groups Projects
Commit a0fd8688 authored by Thomas Faivre's avatar Thomas Faivre Committed by Guillaume Valadon
Browse files

Fix FlagValue dump behavior.


When running the command method on a packet, by default, the __repr__
method of the value is used to dump a field.
Although, the __repr__ method of the new FlagValue class is not a valid
python syntax:

In [2]: IP(flags=0).command()
Out[2]: 'IP(flags=<Flag 0 ()>)'

In [3]: IP(flags=<Flag 0 ()>)
  File "<ipython-input-3-1e8a4a1eb25a>", line 1
    IP(flags=<Flag 0 ()>)
             ^
SyntaxError: invalid syntax

Also, when print a FlagValue with value of 0, flagrepr returns an empty
string which can be confusing:

In [1]: IP(flags=0)
Out[1]: <IP  flags= |>

Use int value instead in both cases.

Fixes: fc6a4caa ("Introduce FlagValue(int) objects to represent FlagsField() values")
Signed-off-by: default avatarThomas Faivre <thomas.faivre@6wind.com>
parent 8ea9b84b
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment