Repository: secdev/scapy

Issue:
Update example to support python3
Tuple unpacking was removed in python3 ([PEP 3113](https://www.python.org/dev/peps/pep-3113/)) so this example will throw `SyntaxError: invalid syntax`.
Update example to support python3
Tuple unpacking was removed in python3 ([PEP 3113](https://www.python.org/dev/peps/pep-3113/)) so this example will throw `SyntaxError: invalid syntax`.


Discussion:
# [Codecov](https://codecov.io/gh/secdev/scapy/pull/2626?src=pr&el=h1) Report
> Merging [#2626](https://codecov.io/gh/secdev/scapy/pull/2626?src=pr&el=desc) into [master](https://codecov.io/gh/secdev/scapy/commit/2233f7305d52802dda510b31f7cfb6d4fa6fec94&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `n/a`.


```diff
@@            Coverage Diff             @@
##           master    #2626      +/-   ##
==========================================
+ Coverage   88.41%   88.42%   +0.01%     
==========================================
  Files         247      247              
  Lines       52178    52178              
==========================================
+ Hits        46135    46141       +6     
+ Misses       6043     6037       -6     
```

| [Impacted Files](https://codecov.io/gh/secdev/scapy/pull/2626?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [scapy/layers/inet.py](https://codecov.io/gh/secdev/scapy/pull/2626/diff?src=pr&el=tree#diff-c2NhcHkvbGF5ZXJzL2luZXQucHk=) | `73.58% <0.00%> (+0.08%)` | :arrow_up: |
| [scapy/layers/http.py](https://codecov.io/gh/secdev/scapy/pull/2626/diff?src=pr&el=tree#diff-c2NhcHkvbGF5ZXJzL2h0dHAucHk=) | `85.62% <0.00%> (+0.63%)` | :arrow_up: |
| [scapy/arch/bpf/core.py](https://codecov.io/gh/secdev/scapy/pull/2626/diff?src=pr&el=tree#diff-c2NhcHkvYXJjaC9icGYvY29yZS5weQ==) | `87.12% <0.00%> (+2.97%)` | :arrow_up: |

# [Codecov](https://codecov.io/gh/secdev/scapy/pull/2626?src=pr&el=h1) Report
> Merging [#2626](https://codecov.io/gh/secdev/scapy/pull/2626?src=pr&el=desc) into [master](https://codecov.io/gh/secdev/scapy/commit/2233f7305d52802dda510b31f7cfb6d4fa6fec94&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `n/a`.


```diff
@@            Coverage Diff             @@
##           master    #2626      +/-   ##
==========================================
+ Coverage   88.41%   88.42%   +0.01%     
==========================================
  Files         247      247              
  Lines       52178    52178              
==========================================
+ Hits        46135    46141       +6     
+ Misses       6043     6037       -6     
```

| [Impacted Files](https://codecov.io/gh/secdev/scapy/pull/2626?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [scapy/layers/inet.py](https://codecov.io/gh/secdev/scapy/pull/2626/diff?src=pr&el=tree#diff-c2NhcHkvbGF5ZXJzL2luZXQucHk=) | `73.58% <0.00%> (+0.08%)` | :arrow_up: |
| [scapy/layers/http.py](https://codecov.io/gh/secdev/scapy/pull/2626/diff?src=pr&el=tree#diff-c2NhcHkvbGF5ZXJzL2h0dHAucHk=) | `85.62% <0.00%> (+0.63%)` | :arrow_up: |
| [scapy/arch/bpf/core.py](https://codecov.io/gh/secdev/scapy/pull/2626/diff?src=pr&el=tree#diff-c2NhcHkvYXJjaC9icGYvY29yZS5weQ==) | `87.12% <0.00%> (+2.97%)` | :arrow_up: |


Resolving patch:
diff --git a/scapy/plist.py b/scapy/plist.py
--- a/scapy/plist.py
+++ b/scapy/plist.py
@@ -146,14 +146,18 @@ def summary(self, prn=None, lfilter=None):
         :param lfilter: truth function to apply to each packet to decide
                         whether it will be displayed
         """
+        # Python 2 backward compatibility
+        prn = lambda_tuple_converter(prn)
+        lfilter = lambda_tuple_converter(lfilter)
+
         for r in self.res:
             if lfilter is not None:
-                if not lfilter(r):
+                if not lfilter(*r):
                     continue
             if prn is None:
                 print(self._elt2sum(r))
             else:
-                print(prn(r))
+                print(prn(*r))
 
     def nsummary(self, prn=None, lfilter=None):
         # type: (Optional[Callable], Optional[Callable]) -> None
@@ -164,15 +168,19 @@ def nsummary(self, prn=None, lfilter=None):
         :param lfilter: truth function to apply to each packet to decide
                         whether it will be displayed
         """
+        # Python 2 backward compatibility
+        prn = lambda_tuple_converter(prn)
+        lfilter = lambda_tuple_converter(lfilter)
+
         for i, res in enumerate(self.res):
             if lfilter is not None:
-                if not lfilter(res):
+                if not lfilter(*res):
                     continue
             print(conf.color_theme.id(i, fmt="%04i"), end=' ')
             if prn is None:
                 print(self._elt2sum(res))
             else:
-                print(prn(res))
+                print(prn(*res))
 
     def display(self):  # Deprecated. Use show()
         """deprecated. is show()"""
@@ -187,7 +195,10 @@ def filter(self, func):
         # type: (Callable) -> PacketList
         """Returns a packet list filtered by a truth function. This truth
         function has to take a packet as the only argument and return a boolean value."""  # noqa: E501
-        return self.__class__([x for x in self.res if func(x)],
+        # Python 2 backward compatibility
+        func = lambda_tuple_converter(func)
+
+        return self.__class__([x for x in self.res if func(*x)],
                               name="filtered %s" % self.listname)
 
     def make_table(self, *args, **kargs):


Test patch: