summaryrefslogtreecommitdiffstats
path: root/Lib/encodings
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2007-11-20 23:31:27 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2007-11-20 23:31:27 (GMT)
commit5087980c1e7e6733983245cd0f209d8770f9686e (patch)
tree21cb48e04503c87abd856791ba2a249a40ff1433 /Lib/encodings
parent8c4592a77ae6b71a4bab8d40bbdcea72a6378cb4 (diff)
downloadcpython-5087980c1e7e6733983245cd0f209d8770f9686e.zip
cpython-5087980c1e7e6733983245cd0f209d8770f9686e.tar.gz
cpython-5087980c1e7e6733983245cd0f209d8770f9686e.tar.bz2
The incremental decoder for utf-7 must preserve its state between calls.
Solves issue1460. Might not be a backport candidate: a new API function was added, and some code may rely on details in utf-7.py.
Diffstat (limited to 'Lib/encodings')
-rw-r--r--Lib/encodings/utf_7.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/Lib/encodings/utf_7.py b/Lib/encodings/utf_7.py
index d78d192..8e0567f 100644
--- a/Lib/encodings/utf_7.py
+++ b/Lib/encodings/utf_7.py
@@ -6,34 +6,31 @@ import codecs
### Codec APIs
-class Codec(codecs.Codec):
+encode = codecs.utf_7_encode
- # Note: Binding these as C functions will result in the class not
- # converting them to methods. This is intended.
- encode = codecs.utf_7_encode
- decode = codecs.utf_7_decode
+def decode(input, errors='strict'):
+ return codecs.utf_7_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_7_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
- def _buffer_decode(self, input, errors, final):
- return codecs.utf_7_decode(input, self.errors)
+ _buffer_decode = codecs.utf_7_decode
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
+class StreamWriter(codecs.StreamWriter):
+ encode = codecs.utf_7_encode
-class StreamReader(Codec,codecs.StreamReader):
- pass
+class StreamReader(codecs.StreamReader):
+ decode = codecs.utf_7_decode
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='utf-7',
- encode=Codec.encode,
- decode=Codec.decode,
+ encode=encode,
+ decode=decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamreader=StreamReader,