cpython: 620d23f7ad41 (original) (raw)

--- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -744,7 +744,7 @@ class CodecCallbackTest(unittest.TestCas raise ValueError self.assertRaises(UnicodeError, codecs.charmap_decode, b"\xff", "strict", {0xff: None}) self.assertRaises(ValueError, codecs.charmap_decode, b"\xff", "strict", D())

def test_encodehelper(self): # enhance coverage of:

--- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1546,6 +1546,10 @@ class CharmapTest(unittest.TestCase): ("abc", 3) )

+ self.assertEqual( codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab"), ("ab\ufffd", 3) @@ -1572,6 +1576,107 @@ class CharmapTest(unittest.TestCase): ("", len(allbytes)) )

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + class WithStmtTest(unittest.TestCase): def test_encodedfile(self): f = io.BytesIO(b"\xc3\xbc")

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2.4 Core and Builtins ----------------- +- Issue #15379: Fix passing of non-BMP characters as integers for the charmap

--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5250,12 +5250,36 @@ PyObject PyUnicode_DecodeCharmap(const / Apply mapping */ if (PyLong_Check(x)) { long value = PyLong_AS_LONG(x);

+ +#ifndef Py_UNICODE_WIDE

+#endif *p++ = (Py_UNICODE)value; } else if (x == Py_None) {