aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-05-15 14:37:42 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2014-05-15 14:37:42 +0300
commit88d8fb6af603176b6e55766da067f84115e35406 (patch)
treee3c6f09e9117def635e418e83b7c46d349ac9d25 /Lib/test/test_codecs.py
parent8e4efbe115b0062d08c394fbdb6b39bb39304fd3 (diff)
downloadcpython-88d8fb6af603176b6e55766da067f84115e35406.tar.gz
cpython-88d8fb6af603176b6e55766da067f84115e35406.zip
Issue #13916: Disallowed the surrogatepass error handler for non UTF-*
encodings.
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 7459010952a..e4d7a601d04 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -2807,6 +2807,9 @@ class CodePageTest(unittest.TestCase):
('[\u20ac]', 'replace', b'[?]'),
('[\xff]', 'backslashreplace', b'[\\xff]'),
('[\xff]', 'xmlcharrefreplace', b'[&#255;]'),
+ ('\udcff', 'strict', None),
+ ('[\udcff]', 'surrogateescape', b'[\xff]'),
+ ('[\udcff]', 'surrogatepass', None),
))
self.check_decode(932, (
(b'abc', 'strict', 'abc'),
@@ -2816,6 +2819,7 @@ class CodePageTest(unittest.TestCase):
(b'[\xff]', 'ignore', '[]'),
(b'[\xff]', 'replace', '[\ufffd]'),
(b'[\xff]', 'surrogateescape', '[\udcff]'),
+ (b'[\xff]', 'surrogatepass', None),
(b'\x81\x00abc', 'strict', None),
(b'\x81\x00abc', 'ignore', '\x00abc'),
(b'\x81\x00abc', 'replace', '\ufffd\x00abc'),
@@ -2826,14 +2830,23 @@ class CodePageTest(unittest.TestCase):
('abc', 'strict', b'abc'),
('\xe9\u20ac', 'strict', b'\xe9\x80'),
('\xff', 'strict', b'\xff'),
+ # test error handlers
('\u0141', 'strict', None),
('\u0141', 'ignore', b''),
('\u0141', 'replace', b'L'),
+ ('\udc98', 'surrogateescape', b'\x98'),
+ ('\udc98', 'surrogatepass', None),
))
self.check_decode(1252, (
(b'abc', 'strict', 'abc'),
(b'\xe9\x80', 'strict', '\xe9\u20ac'),
(b'\xff', 'strict', '\xff'),
+ # invalid bytes
+ (b'[\x98]', 'strict', None),
+ (b'[\x98]', 'ignore', '[]'),
+ (b'[\x98]', 'replace', '[\ufffd]'),
+ (b'[\x98]', 'surrogateescape', '[\udc98]'),
+ (b'[\x98]', 'surrogatepass', None),
))
def test_cp_utf7(self):