mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Merged revisions 76710 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r76710 | antoine.pitrou | 2009-12-08 16:57:31 +0100 (mar., 08 déc. 2009) | 10 lines Merged revisions 76708 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76708 | antoine.pitrou | 2009-12-08 16:40:51 +0100 (mar., 08 déc. 2009) | 4 lines Issue #6986: Fix crash in the JSON C accelerator when called with the wrong parameter types. Patch by Victor Stinner. ........ ................
This commit is contained in:
parent
60a32c8c0b
commit
4fad6bdde9
3 changed files with 29 additions and 6 deletions
|
@ -1,8 +1,7 @@
|
||||||
import decimal
|
import decimal
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from json import decoder
|
from json import decoder, encoder, scanner
|
||||||
from json import encoder
|
|
||||||
|
|
||||||
class TestSpeedups(TestCase):
|
class TestSpeedups(TestCase):
|
||||||
def test_scanstring(self):
|
def test_scanstring(self):
|
||||||
|
@ -13,3 +12,13 @@ class TestSpeedups(TestCase):
|
||||||
self.assertEquals(encoder.encode_basestring_ascii.__module__, "_json")
|
self.assertEquals(encoder.encode_basestring_ascii.__module__, "_json")
|
||||||
self.assertTrue(encoder.encode_basestring_ascii is
|
self.assertTrue(encoder.encode_basestring_ascii is
|
||||||
encoder.c_encode_basestring_ascii)
|
encoder.c_encode_basestring_ascii)
|
||||||
|
|
||||||
|
class TestDecode(TestCase):
|
||||||
|
def test_make_scanner(self):
|
||||||
|
self.assertRaises(AttributeError, scanner.c_make_scanner, 1)
|
||||||
|
|
||||||
|
def test_make_encoder(self):
|
||||||
|
self.assertRaises(TypeError, encoder.c_make_encoder,
|
||||||
|
(True, False),
|
||||||
|
b"\xCD\x7D\x3D\x4E\x12\x4C\xF9\x79\xD7\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75",
|
||||||
|
None)
|
||||||
|
|
|
@ -55,6 +55,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #6986: Fix crash in the JSON C accelerator when called with the
|
||||||
|
wrong parameter types. Patch by Victor Stinner.
|
||||||
|
|
||||||
- Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is
|
- Issue #1923: Fixed the removal of meaningful spaces when PKG-INFO is
|
||||||
generated in Distutils. Patch by Stephen Emslie.
|
generated in Distutils. Patch by Stephen Emslie.
|
||||||
|
|
||||||
|
|
|
@ -1123,15 +1123,28 @@ encoder_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
static char *kwlist[] = {"markers", "default", "encoder", "indent", "key_separator", "item_separator", "sort_keys", "skipkeys", "allow_nan", NULL};
|
static char *kwlist[] = {"markers", "default", "encoder", "indent", "key_separator", "item_separator", "sort_keys", "skipkeys", "allow_nan", NULL};
|
||||||
|
|
||||||
PyEncoderObject *s;
|
PyEncoderObject *s;
|
||||||
PyObject *allow_nan;
|
PyObject *markers, *defaultfn, *encoder, *indent, *key_separator;
|
||||||
|
PyObject *item_separator, *sort_keys, *skipkeys, *allow_nan;
|
||||||
|
|
||||||
assert(PyEncoder_Check(self));
|
assert(PyEncoder_Check(self));
|
||||||
s = (PyEncoderObject *)self;
|
s = (PyEncoderObject *)self;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOOOO:make_encoder", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOOOO:make_encoder", kwlist,
|
||||||
&s->markers, &s->defaultfn, &s->encoder, &s->indent, &s->key_separator, &s->item_separator, &s->sort_keys, &s->skipkeys, &allow_nan))
|
&markers, &defaultfn, &encoder, &indent, &key_separator, &item_separator,
|
||||||
|
&sort_keys, &skipkeys, &allow_nan))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
s->markers = markers;
|
||||||
|
s->defaultfn = defaultfn;
|
||||||
|
s->encoder = encoder;
|
||||||
|
s->indent = indent;
|
||||||
|
s->key_separator = key_separator;
|
||||||
|
s->item_separator = item_separator;
|
||||||
|
s->sort_keys = sort_keys;
|
||||||
|
s->skipkeys = skipkeys;
|
||||||
|
s->fast_encode = (PyCFunction_Check(s->encoder) && PyCFunction_GetFunction(s->encoder) == (PyCFunction)py_encode_basestring_ascii);
|
||||||
|
s->allow_nan = PyObject_IsTrue(allow_nan);
|
||||||
|
|
||||||
Py_INCREF(s->markers);
|
Py_INCREF(s->markers);
|
||||||
Py_INCREF(s->defaultfn);
|
Py_INCREF(s->defaultfn);
|
||||||
Py_INCREF(s->encoder);
|
Py_INCREF(s->encoder);
|
||||||
|
@ -1140,8 +1153,6 @@ encoder_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
Py_INCREF(s->item_separator);
|
Py_INCREF(s->item_separator);
|
||||||
Py_INCREF(s->sort_keys);
|
Py_INCREF(s->sort_keys);
|
||||||
Py_INCREF(s->skipkeys);
|
Py_INCREF(s->skipkeys);
|
||||||
s->fast_encode = (PyCFunction_Check(s->encoder) && PyCFunction_GetFunction(s->encoder) == (PyCFunction)py_encode_basestring_ascii);
|
|
||||||
s->allow_nan = PyObject_IsTrue(allow_nan);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue