Implements PEP-0343

This commit is contained in:
nico@chdir.org 2013-08-02 19:29:41 +02:00
parent 9d4a1202b7
commit c79a2ff897
1 changed files with 14 additions and 2 deletions

View File

@ -560,7 +560,12 @@ class RawPcapReader:
def close(self):
return self.f.close()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, tracback):
pass
class PcapReader(RawPcapReader):
def __init__(self, filename):
@ -673,9 +678,16 @@ class RawPcapWriter:
def flush(self):
return self.f.flush()
def close(self):
return self.f.close()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, tracback):
self.flush()
class PcapWriter(RawPcapWriter):
def _write_header(self, pkt):
if self.linktype == None: