diff --git a/scapy/packet.py b/scapy/packet.py index 9a6d73ecee54e47f211201ca20ba894e40cfe8c1..d5ff45268eea4d05f1c2dfd16ea2a8b810f48344 100644 --- a/scapy/packet.py +++ b/scapy/packet.py @@ -1283,7 +1283,8 @@ def ls(obj=None, case_sensitive=False, verbose=False): attrs = [] long_attrs = [] while isinstance(cur_fld, (Emph, ConditionalField)): - attrs.append(cur_fld.__class__.__name__[:4]) + if isinstance(cur_fld, ConditionalField): + attrs.append(cur_fld.__class__.__name__[:4]) cur_fld = cur_fld.fld if verbose and isinstance(cur_fld, EnumField) \ and hasattr(cur_fld, "i2s"): @@ -1309,10 +1310,7 @@ def ls(obj=None, case_sensitive=False, verbose=False): ) elif verbose and isinstance(cur_fld, FlagsField): names = cur_fld.names - if isinstance(names, basestring): - long_attrs.append(", ".join(names)) - else: - long_attrs.append(", ".join(name[0] for name in names)) + long_attrs.append(", ".join(names)) class_name = "%s (%s)" % ( cur_fld.__class__.__name__, ", ".join(attrs)) if attrs else cur_fld.__class__.__name__ @@ -1322,7 +1320,7 @@ def ls(obj=None, case_sensitive=False, verbose=False): else "") print "%-10s : %-35s =" % (f.name, class_name), if is_pkt: - print "%-15r" % getattr(obj,f.name), + print "%-15r" % (getattr(obj, f.name),), print "(%r)" % (f.default,) for attr in long_attrs: print "%-15s%s" % ("", attr) diff --git a/test/regression.uts b/test/regression.uts index 06ec3d0f7c2d48f18b86f72db8ed3cf1b6f721a9..fe8c8c5706dc50da2cb7cc9fb10096c161be88f4 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -771,6 +771,7 @@ all(x[1] == 15169 for x in ret) = Implicit logic ~ IP TCP a=IP(ttl=(5,10))/TCP(dport=[80,443]) +ls(a) [p for p in a] len(_) == 12