cpython: 4f47509d7417 (original) (raw)
Mercurial > cpython
changeset 94439:4f47509d7417 3.4
merge 3.3 (#23369) [#23369]
Benjamin Peterson benjamin@python.org | |
---|---|
date | Sun, 01 Feb 2015 17:59:49 -0500 |
parents | 24e3371cec2d(current diff)8699b3085db3(diff) |
children | 02aeca4974ac a8737f0bbb7a |
files | Lib/test/test_unicode.py Misc/NEWS Modules/_json.c Objects/unicodeobject.c |
diffstat | 3 files changed, 22 insertions(+), 5 deletions(-)[+] [-] Lib/test/test_json/test_encode_basestring_ascii.py 9 Misc/NEWS 3 Modules/_json.c 15 |
line wrap: on
line diff
--- a/Lib/test/test_json/test_encode_basestring_ascii.py +++ b/Lib/test/test_json/test_encode_basestring_ascii.py @@ -1,5 +1,6 @@ from collections import OrderedDict from test.test_json import PyTest, CTest +from test.support import bigaddrspacetest CASES = [ @@ -41,4 +42,10 @@ class TestEncodeBasestringAscii: class TestPyEncodeBasestringAscii(TestEncodeBasestringAscii, PyTest): pass -class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest): pass +class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest):
- @bigaddrspacetest
- def test_overflow(self):
s = "\uffff"*((2**32)//6 + 1)[](#l1.18)
with self.assertRaises(OverflowError):[](#l1.19)
self.json.encoder.encode_basestring_ascii(s)[](#l1.20)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,9 @@ Core and Builtins Library ------- +- Issue #23369: Fixed possible integer overflow in
- Issue #23353: Fix the exception handling of generators in PyEval_EvalFrameEx(). At entry, save or swap the exception state even if PyEval_EvalFrameEx() is called with throwflag=0. At exit, the exception state
--- a/Modules/_json.c +++ b/Modules/_json.c @@ -182,17 +182,24 @@ ascii_escape_unicode(PyObject pystr) / Compute the output size */ for (i = 0, output_size = 2; i < input_chars; i++) { Py_UCS4 c = PyUnicode_READ(kind, input, i);
if (S_CHAR(c))[](#l4.7)
output_size++;[](#l4.8)
Py_ssize_t d;[](#l4.9)
if (S_CHAR(c)) {[](#l4.10)
d = 1;[](#l4.11)
}[](#l4.12) else {[](#l4.13) switch(c) {[](#l4.14) case '\\': case '"': case '\b': case '\f':[](#l4.15) case '\n': case '\r': case '\t':[](#l4.16)
output_size += 2; break;[](#l4.17)
d = 2; break;[](#l4.18) default:[](#l4.19)
output_size += c >= 0x10000 ? 12 : 6;[](#l4.20)