diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-01 18:34:16 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-01 18:34:16 (GMT) |
commit | cbb028466b6d303c40daef2e5a2f3e072dc0fa94 (patch) | |
tree | 5661dab9138b717bca4633ef7ef18040a69ab2af /Modules | |
parent | f02f280b87bcad54b4ff735cc8642a7d6b7ee23c (diff) | |
download | cpython-cbb028466b6d303c40daef2e5a2f3e072dc0fa94.zip cpython-cbb028466b6d303c40daef2e5a2f3e072dc0fa94.tar.gz cpython-cbb028466b6d303c40daef2e5a2f3e072dc0fa94.tar.bz2 |
Issue #16590: remove obsolete compatibility code from the _json module.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_json.c | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/Modules/_json.c b/Modules/_json.c index dbe3bad..9b6bbd3 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -2,20 +2,6 @@ #include "structmember.h" #include "accu.h" -#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TYPE) -#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) -#endif -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -#define PY_SSIZE_T_MAX INT_MAX -#define PY_SSIZE_T_MIN INT_MIN -#define PyInt_FromSsize_t PyInt_FromLong -#define PyInt_AsSsize_t PyInt_AsLong -#endif -#ifndef Py_IS_FINITE -#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) -#endif - #ifdef __GNUC__ #define UNUSED __attribute__((__unused__)) #else @@ -129,33 +115,12 @@ static void raise_errmsg(char *msg, PyObject *s, Py_ssize_t end); static PyObject * encoder_encode_string(PyEncoderObject *s, PyObject *obj); -static int -_convertPyInt_AsSsize_t(PyObject *o, Py_ssize_t *size_ptr); -static PyObject * -_convertPyInt_FromSsize_t(Py_ssize_t *size_ptr); static PyObject * encoder_encode_float(PyEncoderObject *s, PyObject *obj); #define S_CHAR(c) (c >= ' ' && c <= '~' && c != '\\' && c != '"') #define IS_WHITESPACE(c) (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r')) -static int -_convertPyInt_AsSsize_t(PyObject *o, Py_ssize_t *size_ptr) -{ - /* PyObject to Py_ssize_t converter */ - *size_ptr = PyLong_AsSsize_t(o); - if (*size_ptr == -1 && PyErr_Occurred()) - return 0; - return 1; -} - -static PyObject * -_convertPyInt_FromSsize_t(Py_ssize_t *size_ptr) -{ - /* Py_ssize_t to PyObject converter */ - return PyLong_FromSsize_t(*size_ptr); -} - static Py_ssize_t ascii_escape_unichar(Py_UCS4 c, unsigned char *output, Py_ssize_t chars) { @@ -265,7 +230,7 @@ raise_errmsg(char *msg, PyObject *s, Py_ssize_t end) if (errmsg_fn == NULL) return; } - pymsg = PyObject_CallFunction(errmsg_fn, "(zOO&)", msg, s, _convertPyInt_FromSsize_t, &end); + pymsg = PyObject_CallFunction(errmsg_fn, "(zOn)", msg, s, end); if (pymsg) { PyErr_SetObject(PyExc_ValueError, pymsg); Py_DECREF(pymsg); @@ -524,7 +489,7 @@ py_scanstring(PyObject* self UNUSED, PyObject *args) Py_ssize_t end; Py_ssize_t next_end = -1; int strict = 1; - if (!PyArg_ParseTuple(args, "OO&|i:scanstring", &pystr, _convertPyInt_AsSsize_t, &end, &strict)) { + if (!PyArg_ParseTuple(args, "On|i:scanstring", &pystr, &end, &strict)) { return NULL; } if (PyUnicode_Check(pystr)) { @@ -1087,7 +1052,7 @@ scanner_call(PyObject *self, PyObject *args, PyObject *kwds) PyScannerObject *s; assert(PyScanner_Check(self)); s = (PyScannerObject *)self; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&:scan_once", kwlist, &pystr, _convertPyInt_AsSsize_t, &idx)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "On:scan_once", kwlist, &pystr, &idx)) return NULL; if (PyUnicode_Check(pystr)) { @@ -1288,8 +1253,8 @@ encoder_call(PyObject *self, PyObject *args, PyObject *kwds) assert(PyEncoder_Check(self)); s = (PyEncoderObject *)self; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&:_iterencode", kwlist, - &obj, _convertPyInt_AsSsize_t, &indent_level)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "On:_iterencode", kwlist, + &obj, &indent_level)) return NULL; if (_PyAccu_Init(&acc)) return NULL; |