[Python-checkins] r51046 - in python/trunk: Lib/encodings/mbcs.py Misc/NEWS Modules/_codecsmodule.c
martin.v.loewis
python-checkins at python.org
Wed Aug 2 15:53:57 CEST 2006
Author: martin.v.loewis
Date: Wed Aug 2 15:53:55 2006
New Revision: 51046
Modified:
python/trunk/Lib/encodings/mbcs.py
python/trunk/Misc/NEWS
python/trunk/Modules/_codecsmodule.c
Log:
Correction of patch #1455898: In the mbcs decoder, set final=False
for stream decoder, but final=True for the decode function.
Modified: python/trunk/Lib/encodings/mbcs.py
==============================================================================
--- python/trunk/Lib/encodings/mbcs.py (original)
+++ python/trunk/Lib/encodings/mbcs.py Wed Aug 2 15:53:55 2006
@@ -15,39 +15,31 @@
### Codec APIs
-class Codec(codecs.Codec):
+encode = mbcs_encode
- # Note: Binding these as C functions will result in the class not
- # converting them to methods. This is intended.
- encode = mbcs_encode
- decode = mbcs_decode
+def decode(input, errors='strict'):
+ return mbcs_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
- return mbcs_encode(input,self.errors)[0]
+ return mbcs_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
- def _buffer_decode(self, input, errors, final):
- return mbcs_decode(input,self.errors,final)
-
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
+ _buffer_decode = mbcs_decode
-class StreamReader(Codec,codecs.StreamReader):
- pass
-
-class StreamConverter(StreamWriter,StreamReader):
+class StreamWriter(codecs.StreamWriter):
+ encode = mbcs_encode
- encode = codecs.mbcs_decode
- decode = codecs.mbcs_encode
+class StreamReader(codecs.StreamReader):
+ decode = mbcs_decode
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='mbcs',
- encode=Codec.encode,
- decode=Codec.decode,
+ encode=encode,
+ decode=decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamreader=StreamReader,
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Wed Aug 2 15:53:55 2006
@@ -64,6 +64,9 @@
Library
-------
+- Correction of patch #1455898: In the mbcs decoder, set final=False
+ for stream decoder, but final=True for the decode function.
+
- os.urandom no longer masks unrelated exceptions like SystemExit or
KeyboardInterrupt.
Modified: python/trunk/Modules/_codecsmodule.c
==============================================================================
--- python/trunk/Modules/_codecsmodule.c (original)
+++ python/trunk/Modules/_codecsmodule.c Wed Aug 2 15:53:55 2006
@@ -481,7 +481,7 @@
const char *data;
Py_ssize_t size, consumed;
const char *errors = NULL;
- int final = 1;
+ int final = 0;
PyObject *decoded;
if (!PyArg_ParseTuple(args, "t#|zi:mbcs_decode",
More information about the Python-checkins
mailing list