From 68ae3366405cd1aecbfbf76f3d268674f058e38e Mon Sep 17 00:00:00 2001
From: Pierre LALET <pierre.lalet@cea.fr>
Date: Sat, 30 Jan 2016 15:13:55 +0100
Subject: [PATCH] rdpcapng: use with statement

---
 scapy/utils.py | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/scapy/utils.py b/scapy/utils.py
index 584a7c20..d3c57899 100644
--- a/scapy/utils.py
+++ b/scapy/utils.py
@@ -535,14 +535,8 @@ count: read only <count> packets"""
 def rdpcapng(filename, count=-1):
     """Read a pcapng file and return a packet list
 count: read only <count> packets"""
-    ## Does not work with Python <= 2.5. Use this implementation as
-    ## soon as we drop support for Python 2.5.
-    # with PcapNgReader(filename) as fdesc:
-    #     return fdesc.read_all(count=count)
-    fdesc = PcapNgReader(filename)
-    result = fdesc.read_all(count=count)
-    fdesc.close()
-    return result
+    with PcapNgReader(filename) as fdesc:
+        return fdesc.read_all(count=count)
 
 
 class RawPcapReader:
-- 
GitLab