summaryrefslogtreecommitdiffstats
path: root/Lib/encodings/bz2_codec.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/encodings/bz2_codec.py')
-rw-r--r--Lib/encodings/bz2_codec.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/encodings/bz2_codec.py b/Lib/encodings/bz2_codec.py
index 870474c..81e84b6 100644
--- a/Lib/encodings/bz2_codec.py
+++ b/Lib/encodings/bz2_codec.py
@@ -51,6 +51,16 @@ class Codec(codecs.Codec):
def decode(self, input, errors='strict'):
return bz2_decode(input, errors)
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ assert self.errors == 'strict'
+ return bz2.compress(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+ def decode(self, input, final=False):
+ assert self.errors == 'strict'
+ return bz2.decompress(input)
+
class StreamWriter(Codec,codecs.StreamWriter):
pass
@@ -60,5 +70,12 @@ class StreamReader(Codec,codecs.StreamReader):
### encodings module API
def getregentry():
-
- return (bz2_encode,bz2_decode,StreamReader,StreamWriter)
+ return codecs.CodecInfo(
+ name="bz2",
+ encode=bz2_encode,
+ decode=bz2_decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamwriter=StreamWriter,
+ streamreader=StreamReader,
+ )