cpython: 218da678bb8b (original) (raw)

Mercurial > cpython

changeset 81806:218da678bb8b

Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. [#16979]

Serhiy Storchaka storchaka@gmail.com
date Tue, 29 Jan 2013 10:37:39 +0200
parents 8b9910d8d27f(current diff)086defaf16fe(diff)
children d2f502cf12f4
files Lib/test/test_codecs.py Misc/NEWS Objects/unicodeobject.c
diffstat 4 files changed, 117 insertions(+), 53 deletions(-)[+] [-] Lib/test/test_codeccallbacks.py 4 Lib/test/test_codecs.py 84 Misc/NEWS 2 Objects/unicodeobject.c 80

line wrap: on

line diff

--- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -271,12 +271,12 @@ class CodecCallbackTest(unittest.TestCas self.assertEqual( b"\u3042\u3xxx".decode("unicode-escape", "test.handler1"),

self.assertEqual( b"\u3042\u3xx".decode("unicode-escape", "test.handler1"),

self.assertEqual(

--- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -21,6 +21,11 @@ except ImportError: else: SIZEOF_WCHAR_T = ctypes.sizeof(ctypes.c_wchar) +def coding_checker(self, coder):

+ class Queue(object): """ queue: write bytes at one end, read bytes from the other end @@ -2009,6 +2014,85 @@ class TypesTest(unittest.TestCase): self.assertRaises(UnicodeDecodeError, codecs.raw_unicode_escape_decode, br"\U00110000") self.assertEqual(codecs.raw_unicode_escape_decode(r"\U00110000", "replace"), ("\ufffd", 10)) + +class UnicodeEscapeTest(unittest.TestCase):

+

+

+

+

+

+ + class SurrogateEscapeTest(unittest.TestCase): def test_utf8(self):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -234,6 +234,8 @@ Core and Builtins Library ------- +- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder. + Have py_compile use importlib as much as possible to avoid code duplication.

--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -5378,7 +5378,6 @@ PyUnicode_DecodeUnicodeEscape(const char const char *starts = s; Py_ssize_t startinpos; Py_ssize_t endinpos;

@@ -5530,24 +5520,16 @@ PyUnicode_DecodeUnicodeEscape(const char else chr += 10 + c - 'A'; }

/* \N{name} */ @@ -5575,26 +5557,13 @@ PyUnicode_DecodeUnicodeEscape(const char goto store; } }

default: if (s > end) { message = "\ at end of string"; s--;

@@ -5602,8 +5571,17 @@ PyUnicode_DecodeUnicodeEscape(const char } break; }

+

#undef WRITECHAR