summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-03-20 19:45:18 (GMT)
committerGitHub <noreply@github.com>2019-03-20 19:45:18 (GMT)
commitc1e2c288f41cdc1c6e6e09d9a5277a58232ceb03 (patch)
tree058299d518ec9061b3b0735f08e0f49c874e733d /Lib
parentcc60cdd9c44dd15e441603ee5f78e09ea3e76929 (diff)
downloadcpython-c1e2c288f41cdc1c6e6e09d9a5277a58232ceb03.zip
cpython-c1e2c288f41cdc1c6e6e09d9a5277a58232ceb03.tar.gz
cpython-c1e2c288f41cdc1c6e6e09d9a5277a58232ceb03.tar.bz2
bpo-36312: Fix decoders for some code pages. (GH-12369)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_codecs.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index e8c7d76..3314493 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -3066,6 +3066,15 @@ class CodePageTest(unittest.TestCase):
('[\U0010ffff\uDC80]', 'replace', b'[\xf4\x8f\xbf\xbf?]'),
))
+ def test_code_page_decode_flags(self):
+ # Issue #36312: For some code pages (e.g. UTF-7) flags for
+ # MultiByteToWideChar() must be set to 0.
+ for cp in (50220, 50221, 50222, 50225, 50227, 50229,
+ *range(57002, 57011+1), 65000):
+ self.assertEqual(codecs.code_page_decode(cp, b'abc'), ('abc', 3))
+ self.assertEqual(codecs.code_page_decode(42, b'abc'),
+ ('\uf061\uf062\uf063', 3))
+
def test_incremental(self):
decoded = codecs.code_page_decode(932, b'\x82', 'strict', False)
self.assertEqual(decoded, ('', 0))