### Bug Summary

File: | Modules/_json.c
Location: | line 338, column 16
Description: | Value stored to 'next' during its initialization is never read

### Annotated Source Code

1 | #include "Python.h"
2 | #include "structmember.h"
3 | #if PY_VERSION_HEX((3 << 24) | (2 << 16) | (0 << 8) | (0xC << 4) | (2 << 0)) < 0x02060000 && !defined(Py_TYPE)
4 | #define Py_TYPE(ob)(((PyObject*)(ob))->ob_type) (((PyObject*)(ob))->ob_type)
5 | #endif
6 | #if PY_VERSION_HEX((3 << 24) | (2 << 16) | (0 << 8) | (0xC << 4) | (2 << 0)) < 0x02050000 && !defined(PY_SSIZE_T_MIN(-((Py_ssize_t)(((size_t)-1)>>1))-1))
7 | typedef int Py_ssize_t;
8 | #define PY_SSIZE_T_MAX((Py_ssize_t)(((size_t)-1)>>1)) INT_MAX2147483647
9 | #define PY_SSIZE_T_MIN(-((Py_ssize_t)(((size_t)-1)>>1))-1) INT_MIN(-2147483647 -1)
10 | #define PyInt_FromSsize_t PyInt_FromLong
11 | #define PyInt_AsSsize_t PyInt_AsLong
12 | #endif
13 | #ifndef Py_IS_FINITE
14 | #define Py_IS_FINITE(X)( sizeof (X) == sizeof(float ) ? __inline_isfinitef((float)(X )) : sizeof (X) == sizeof(double) ? __inline_isfinited((double )(X)) : __inline_isfinite ((long double)(X))) (!Py_IS_INFINITY(X)( sizeof (X) == sizeof(float ) ? __inline_isinff((float)(X)) : sizeof (X) == sizeof(double) ? __inline_isinfd((double)(X)) : __inline_isinf ((long double)(X))) && !Py_IS_NAN(X)( sizeof (X) == sizeof(float ) ? __inline_isnanf((float)(X)) : sizeof (X) == sizeof(double) ? __inline_isnand((double)(X)) : __inline_isnan ((long double)(X))))
15 | #endif
16 |
17 | #ifdef __GNUC__4
18 | #define UNUSED__attribute__((__unused__)) __attribute__((__unused__))
19 | #else
20 | #define UNUSED__attribute__((__unused__))
21 | #endif
22 |
23 | #define PyScanner_Check(op)((((PyObject*)(op))->ob_type) == (&PyScannerType) || PyType_IsSubtype ((((PyObject*)(op))->ob_type), (&PyScannerType))) PyObject_TypeCheck(op, &PyScannerType)((((PyObject*)(op))->ob_type) == (&PyScannerType) || PyType_IsSubtype ((((PyObject*)(op))->ob_type), (&PyScannerType)))
24 | #define PyScanner_CheckExact(op)((((PyObject*)(op))->ob_type) == &PyScannerType) (Py_TYPE(op)(((PyObject*)(op))->ob_type) == &PyScannerType)
25 | #define PyEncoder_Check(op)((((PyObject*)(op))->ob_type) == (&PyEncoderType) || PyType_IsSubtype ((((PyObject*)(op))->ob_type), (&PyEncoderType))) PyObject_TypeCheck(op, &PyEncoderType)((((PyObject*)(op))->ob_type) == (&PyEncoderType) || PyType_IsSubtype ((((PyObject*)(op))->ob_type), (&PyEncoderType)))
26 | #define PyEncoder_CheckExact(op)((((PyObject*)(op))->ob_type) == &PyEncoderType) (Py_TYPE(op)(((PyObject*)(op))->ob_type) == &PyEncoderType)
27 |
28 | static PyTypeObject PyScannerType;
29 | static PyTypeObject PyEncoderType;
30 |
31 | typedef struct _PyScannerObject {
32 | PyObject_HEADPyObject ob_base;
33 | PyObject *strict;
34 | PyObject *object_hook;
35 | PyObject *object_pairs_hook;
36 | PyObject *parse_float;
37 | PyObject *parse_int;
38 | PyObject *parse_constant;
39 | PyObject *memo;
40 | } PyScannerObject;
41 |
42 | static PyMemberDef scanner_members[] = {
43 | {"strict", T_OBJECT6, offsetof(PyScannerObject, strict)__builtin_offsetof(PyScannerObject, strict), READONLY1, "strict"},
44 | {"object_hook", T_OBJECT6, offsetof(PyScannerObject, object_hook)__builtin_offsetof(PyScannerObject, object_hook), READONLY1, "object_hook"},
45 | {"object_pairs_hook", T_OBJECT6, offsetof(PyScannerObject, object_pairs_hook)__builtin_offsetof(PyScannerObject, object_pairs_hook), READONLY1},
46 | {"parse_float", T_OBJECT6, offsetof(PyScannerObject, parse_float)__builtin_offsetof(PyScannerObject, parse_float), READONLY1, "parse_float"},
47 | {"parse_int", T_OBJECT6, offsetof(PyScannerObject, parse_int)__builtin_offsetof(PyScannerObject, parse_int), READONLY1, "parse_int"},
48 | {"parse_constant", T_OBJECT6, offsetof(PyScannerObject, parse_constant)__builtin_offsetof(PyScannerObject, parse_constant), READONLY1, "parse_constant"},
49 | {NULL((void*)0)}
50 | };
51 |
52 | typedef struct _PyEncoderObject {
53 | PyObject_HEADPyObject ob_base;
54 | PyObject *markers;
55 | PyObject *defaultfn;
56 | PyObject *encoder;
57 | PyObject *indent;
58 | PyObject *key_separator;
59 | PyObject *item_separator;
60 | PyObject *sort_keys;
61 | PyObject *skipkeys;
62 | int fast_encode;
63 | int allow_nan;
64 | } PyEncoderObject;
65 |
66 | static PyMemberDef encoder_members[] = {
67 | {"markers", T_OBJECT6, offsetof(PyEncoderObject, markers)__builtin_offsetof(PyEncoderObject, markers), READONLY1, "markers"},
68 | {"default", T_OBJECT6, offsetof(PyEncoderObject, defaultfn)__builtin_offsetof(PyEncoderObject, defaultfn), READONLY1, "default"},
69 | {"encoder", T_OBJECT6, offsetof(PyEncoderObject, encoder)__builtin_offsetof(PyEncoderObject, encoder), READONLY1, "encoder"},
70 | {"indent", T_OBJECT6, offsetof(PyEncoderObject, indent)__builtin_offsetof(PyEncoderObject, indent), READONLY1, "indent"},
71 | {"key_separator", T_OBJECT6, offsetof(PyEncoderObject, key_separator)__builtin_offsetof(PyEncoderObject, key_separator), READONLY1, "key_separator"},
72 | {"item_separator", T_OBJECT6, offsetof(PyEncoderObject, item_separator)__builtin_offsetof(PyEncoderObject, item_separator), READONLY1, "item_separator"},
73 | {"sort_keys", T_OBJECT6, offsetof(PyEncoderObject, sort_keys)__builtin_offsetof(PyEncoderObject, sort_keys), READONLY1, "sort_keys"},
74 | {"skipkeys", T_OBJECT6, offsetof(PyEncoderObject, skipkeys)__builtin_offsetof(PyEncoderObject, skipkeys), READONLY1, "skipkeys"},
75 | {NULL((void*)0)}
76 | };
77 |
78 | static PyObject *
79 | ascii_escape_unicode(PyObject *pystr);
80 | static PyObject *
81 | py_encode_basestring_ascii(PyObject* self UNUSED__attribute__((__unused__)), PyObject *pystr);
82 | void init_json(void);
83 | static PyObject *
84 | scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr);
85 | static PyObject *
86 | _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx);
87 | static PyObject *
88 | scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
89 | static int
90 | scanner_init(PyObject *self, PyObject *args, PyObject *kwds);
91 | static void
92 | scanner_dealloc(PyObject *self);
93 | static int
94 | scanner_clear(PyObject *self);
95 | static PyObject *
96 | encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
97 | static int
98 | encoder_init(PyObject *self, PyObject *args, PyObject *kwds);
99 | static void
100 | encoder_dealloc(PyObject *self);
101 | static int
102 | encoder_clear(PyObject *self);
103 | static int
104 | encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ssize_t indent_level);
105 | static int
106 | encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssize_t indent_level);
107 | static int
108 | encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ssize_t indent_level);
109 | static PyObject *
110 | _encoded_const(PyObject *obj);
111 | static void
112 | raise_errmsg(char *msg, PyObject *s, Py_ssize_t end);
113 | static PyObject *
114 | encoder_encode_string(PyEncoderObject *s, PyObject *obj);
115 | static int
116 | _convertPyInt_AsSsize_t(PyObject *o, Py_ssize_t *size_ptr);
117 | static PyObject *
118 | _convertPyInt_FromSsize_t(Py_ssize_t *size_ptr);
119 | static PyObject *
120 | encoder_encode_float(PyEncoderObject *s, PyObject *obj);
121 |
122 | #define S_CHAR(c)(c >= ' ' && c <= '~' && c != '\\' && c != '"') (c >= ' ' && c <= '~' && c != '\\' && c != '"')
123 | #define IS_WHITESPACE(c)(((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r' )) (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r'))
124 |
125 | #define MIN_EXPANSION6 6
126 | #ifdef Py_UNICODE_WIDE
127 | #define MAX_EXPANSION6 (2 * MIN_EXPANSION6)
128 | #else
129 | #define MAX_EXPANSION6 MIN_EXPANSION6
130 | #endif
131 |
132 | static int
133 | _convertPyInt_AsSsize_t(PyObject *o, Py_ssize_t *size_ptr)
134 | {
135 | /* PyObject to Py_ssize_t converter */
136 | *size_ptr = PyLong_AsSsize_t(o);
137 | if (*size_ptr == -1 && PyErr_Occurred())
138 | return 0;
139 | return 1;
140 | }
141 |
142 | static PyObject *
143 | _convertPyInt_FromSsize_t(Py_ssize_t *size_ptr)
144 | {
145 | /* Py_ssize_t to PyObject converter */
146 | return PyLong_FromSsize_t(*size_ptr);
147 | }
148 |
149 | static Py_ssize_t
150 | ascii_escape_unichar(Py_UNICODE c, Py_UNICODE *output, Py_ssize_t chars)
151 | {
152 | /* Escape unicode code point c to ASCII escape sequences
153 | in char *output. output must have at least 12 bytes unused to
154 | accommodate an escaped surrogate pair "\uXXXX\uXXXX" */
155 | output[chars++] = '\\';
156 | switch (c) {
157 | case '\\': output[chars++] = c; break;
158 | case '"': output[chars++] = c; break;
159 | case '\b': output[chars++] = 'b'; break;
160 | case '\f': output[chars++] = 'f'; break;
161 | case '\n': output[chars++] = 'n'; break;
162 | case '\r': output[chars++] = 'r'; break;
163 | case '\t': output[chars++] = 't'; break;
164 | default:
165 | #ifdef Py_UNICODE_WIDE
166 | if (c >= 0x10000) {
167 | /* UTF-16 surrogate pair */
168 | Py_UNICODE v = c - 0x10000;
169 | c = 0xd800 | ((v >> 10) & 0x3ff);
170 | output[chars++] = 'u';
171 | output[chars++] = "0123456789abcdef"[(c >> 12) & 0xf];
172 | output[chars++] = "0123456789abcdef"[(c >> 8) & 0xf];
173 | output[chars++] = "0123456789abcdef"[(c >> 4) & 0xf];
174 | output[chars++] = "0123456789abcdef"[(c ) & 0xf];
175 | c = 0xdc00 | (v & 0x3ff);
176 | output[chars++] = '\\';
177 | }
178 | #endif
179 | output[chars++] = 'u';
180 | output[chars++] = "0123456789abcdef"[(c >> 12) & 0xf];
181 | output[chars++] = "0123456789abcdef"[(c >> 8) & 0xf];
182 | output[chars++] = "0123456789abcdef"[(c >> 4) & 0xf];
183 | output[chars++] = "0123456789abcdef"[(c ) & 0xf];
184 | }
185 | return chars;
186 | }
187 |
188 | static PyObject *
189 | ascii_escape_unicode(PyObject *pystr)
190 | {
191 | /* Take a PyUnicode pystr and return a new ASCII-only escaped PyUnicode */
192 | Py_ssize_t i;
193 | Py_ssize_t input_chars;
194 | Py_ssize_t output_size;
195 | Py_ssize_t max_output_size;
196 | Py_ssize_t chars;
197 | PyObject *rval;
198 | Py_UNICODE *output;
199 | Py_UNICODE *input_unicode;
200 |
201 | input_chars = PyUnicode_GET_SIZE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 201, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->length));
202 | input_unicode = PyUnicode_AS_UNICODE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 202, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->str));
203 |
204 | /* One char input can be up to 6 chars output, estimate 4 of these */
205 | output_size = 2 + (MIN_EXPANSION6 * 4) + input_chars;
206 | max_output_size = 2 + (input_chars * MAX_EXPANSION6);
207 | rval = PyUnicode_FromStringAndSizePyUnicodeUCS2_FromStringAndSize(NULL((void*)0), output_size);
208 | if (rval == NULL((void*)0)) {
209 | return NULL((void*)0);
210 | }
211 | output = PyUnicode_AS_UNICODE(rval)((__builtin_expect(!(((((((PyObject*)(rval))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 211, "PyUnicode_Check(rval)" ) : (void)0),(((PyUnicodeObject *)(rval))->str));
212 | chars = 0;
213 | output[chars++] = '"';
214 | for (i = 0; i < input_chars; i++) {
215 | Py_UNICODE c = input_unicode[i];
216 | if (S_CHAR(c)(c >= ' ' && c <= '~' && c != '\\' && c != '"')) {
217 | output[chars++] = c;
218 | }
219 | else {
220 | chars = ascii_escape_unichar(c, output, chars);
221 | }
222 | if (output_size - chars < (1 + MAX_EXPANSION6)) {
223 | /* There's more than four, so let's resize by a lot */
224 | Py_ssize_t new_output_size = output_size * 2;
225 | /* This is an upper bound */
226 | if (new_output_size > max_output_size) {
227 | new_output_size = max_output_size;
228 | }
229 | /* Make sure that the output size changed before resizing */
230 | if (new_output_size != output_size) {
231 | output_size = new_output_size;
232 | if (PyUnicode_ResizePyUnicodeUCS2_Resize(&rval, output_size) == -1) {
233 | return NULL((void*)0);
234 | }
235 | output = PyUnicode_AS_UNICODE(rval)((__builtin_expect(!(((((((PyObject*)(rval))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 235, "PyUnicode_Check(rval)" ) : (void)0),(((PyUnicodeObject *)(rval))->str));
236 | }
237 | }
238 | }
239 | output[chars++] = '"';
240 | if (PyUnicode_ResizePyUnicodeUCS2_Resize(&rval, chars) == -1) {
241 | return NULL((void*)0);
242 | }
243 | return rval;
244 | }
245 |
246 | static void
247 | raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
248 | {
249 | /* Use the Python function json.decoder.errmsg to raise a nice
250 | looking ValueError exception */
251 | static PyObject *errmsg_fn = NULL((void*)0);
252 | PyObject *pymsg;
253 | if (errmsg_fn == NULL((void*)0)) {
254 | PyObject *decoder = PyImport_ImportModule("json.decoder");
255 | if (decoder == NULL((void*)0))
256 | return;
257 | errmsg_fn = PyObject_GetAttrString(decoder, "errmsg");
258 | Py_DECREF(decoder)do { if (_Py_RefTotal-- , --((PyObject*)(decoder))->ob_refcnt != 0) { if (((PyObject*)decoder)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 258, (PyObject *)(decoder)); } else _Py_Dealloc((PyObject *)(decoder)); } while (0);
259 | if (errmsg_fn == NULL((void*)0))
260 | return;
261 | }
262 | pymsg = PyObject_CallFunction(errmsg_fn, "(zOO&)", msg, s, _convertPyInt_FromSsize_t, &end);
263 | if (pymsg) {
264 | PyErr_SetObject(PyExc_ValueError, pymsg);
265 | Py_DECREF(pymsg)do { if (_Py_RefTotal-- , --((PyObject*)(pymsg))->ob_refcnt != 0) { if (((PyObject*)pymsg)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 265, (PyObject *)(pymsg)); } else _Py_Dealloc((PyObject *)(pymsg)); } while (0);
266 | }
267 | }
268 |
269 | static PyObject *
270 | join_list_unicode(PyObject *lst)
271 | {
272 | /* return u''.join(lst) */
273 | static PyObject *sep = NULL((void*)0);
274 | if (sep == NULL((void*)0)) {
275 | sep = PyUnicode_FromStringAndSizePyUnicodeUCS2_FromStringAndSize("", 0);
276 | if (sep == NULL((void*)0))
277 | return NULL((void*)0);
278 | }
279 | return PyUnicode_JoinPyUnicodeUCS2_Join(sep, lst);
280 | }
281 |
282 | static PyObject *
283 | _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx) {
284 | /* return (rval, idx) tuple, stealing reference to rval */
285 | PyObject *tpl;
286 | PyObject *pyidx;
287 | /*
288 | steal a reference to rval, returns (rval, idx)
289 | */
290 | if (rval == NULL((void*)0)) {
291 | return NULL((void*)0);
292 | }
293 | pyidx = PyLong_FromSsize_t(idx);
294 | if (pyidx == NULL((void*)0)) {
295 | Py_DECREF(rval)do { if (_Py_RefTotal-- , --((PyObject*)(rval))->ob_refcnt != 0) { if (((PyObject*)rval)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 295, (PyObject *)(rval)); } else _Py_Dealloc((PyObject *)(rval)); } while ( 0);
296 | return NULL((void*)0);
297 | }
298 | tpl = PyTuple_New(2);
299 | if (tpl == NULL((void*)0)) {
300 | Py_DECREF(pyidx)do { if (_Py_RefTotal-- , --((PyObject*)(pyidx))->ob_refcnt != 0) { if (((PyObject*)pyidx)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 300, (PyObject *)(pyidx)); } else _Py_Dealloc((PyObject *)(pyidx)); } while (0);
301 | Py_DECREF(rval)do { if (_Py_RefTotal-- , --((PyObject*)(rval))->ob_refcnt != 0) { if (((PyObject*)rval)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 301, (PyObject *)(rval)); } else _Py_Dealloc((PyObject *)(rval)); } while ( 0);
302 | return NULL((void*)0);
303 | }
304 | PyTuple_SET_ITEM(tpl, 0, rval)(((PyTupleObject *)(tpl))->ob_item[0] = rval);
305 | PyTuple_SET_ITEM(tpl, 1, pyidx)(((PyTupleObject *)(tpl))->ob_item[1] = pyidx);
306 | return tpl;
307 | }
308 |
309 | #define APPEND_OLD_CHUNKif (chunk != ((void*)0)) { if (chunks == ((void*)0)) { chunks = PyList_New(0); if (chunks == ((void*)0)) { goto bail; } } if (PyList_Append(chunks, chunk)) { do { if (_Py_RefTotal-- , -- ((PyObject*)(chunk))->ob_refcnt != 0) { if (((PyObject*)chunk )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 309, (PyObject *)(chunk)); } else _Py_Dealloc((PyObject *)( chunk)); } while (0); goto bail; } do { if (chunk) { PyObject *_py_tmp = (PyObject *)(chunk); (chunk) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 309, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0); } \
310 | if (chunk != NULL((void*)0)) { \
311 | if (chunks == NULL((void*)0)) { \
312 | chunks = PyList_New(0); \
313 | if (chunks == NULL((void*)0)) { \
314 | goto bail; \
315 | } \
316 | } \
317 | if (PyList_Append(chunks, chunk)) { \
318 | Py_DECREF(chunk)do { if (_Py_RefTotal-- , --((PyObject*)(chunk))->ob_refcnt != 0) { if (((PyObject*)chunk)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 318, (PyObject *)(chunk)); } else _Py_Dealloc((PyObject *)(chunk)); } while (0); \
319 | goto bail; \
320 | } \
321 | Py_CLEAR(chunk)do { if (chunk) { PyObject *_py_tmp = (PyObject *)(chunk); (chunk ) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 321, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0); \
322 | }
323 |
324 | static PyObject *
325 | scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict, Py_ssize_t *next_end_ptr)
326 | {
327 | /* Read the JSON string from PyUnicode pystr.
328 | end is the index of the first character after the quote.
329 | if strict is zero then literal control characters are allowed
330 | *next_end_ptr is a return-by-reference index of the character
331 | after the end quote
332 |
333 | Return value is a new PyUnicode
334 | */
335 | PyObject *rval = NULL((void*)0);
336 | Py_ssize_t len = PyUnicode_GET_SIZE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 336, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->length));
337 | Py_ssize_t begin = end - 1;
338 | Py_ssize_t next = begin;
| Value stored to 'next' during its initialization is never read
339 | const Py_UNICODE *buf = PyUnicode_AS_UNICODE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 339, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->str));
340 | PyObject *chunks = NULL((void*)0);
341 | PyObject *chunk = NULL((void*)0);
342 |
343 | if (end < 0 || len <= end) {
344 | PyErr_SetString(PyExc_ValueError, "end is out of bounds");
345 | goto bail;
346 | }
347 | while (1) {
348 | /* Find the end of the string or the next escape */
349 | Py_UNICODE c = 0;
350 | for (next = end; next < len; next++) {
351 | c = buf[next];
352 | if (c == '"' || c == '\\') {
353 | break;
354 | }
355 | else if (strict && c <= 0x1f) {
356 | raise_errmsg("Invalid control character at", pystr, next);
357 | goto bail;
358 | }
359 | }
360 | if (!(c == '"' || c == '\\')) {
361 | raise_errmsg("Unterminated string starting at", pystr, begin);
362 | goto bail;
363 | }
364 | /* Pick up this chunk if it's not zero length */
365 | if (next != end) {
366 | APPEND_OLD_CHUNKif (chunk != ((void*)0)) { if (chunks == ((void*)0)) { chunks = PyList_New(0); if (chunks == ((void*)0)) { goto bail; } } if (PyList_Append(chunks, chunk)) { do { if (_Py_RefTotal-- , -- ((PyObject*)(chunk))->ob_refcnt != 0) { if (((PyObject*)chunk )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 366, (PyObject *)(chunk)); } else _Py_Dealloc((PyObject *)( chunk)); } while (0); goto bail; } do { if (chunk) { PyObject *_py_tmp = (PyObject *)(chunk); (chunk) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 366, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0); }
367 | chunk = PyUnicode_FromUnicodePyUnicodeUCS2_FromUnicode(&buf[end], next - end);
368 | if (chunk == NULL((void*)0)) {
369 | goto bail;
370 | }
371 | }
372 | next++;
373 | if (c == '"') {
374 | end = next;
375 | break;
376 | }
377 | if (next == len) {
378 | raise_errmsg("Unterminated string starting at", pystr, begin);
379 | goto bail;
380 | }
381 | c = buf[next];
382 | if (c != 'u') {
383 | /* Non-unicode backslash escapes */
384 | end = next + 1;
385 | switch (c) {
386 | case '"': break;
387 | case '\\': break;
388 | case '/': break;
389 | case 'b': c = '\b'; break;
390 | case 'f': c = '\f'; break;
391 | case 'n': c = '\n'; break;
392 | case 'r': c = '\r'; break;
393 | case 't': c = '\t'; break;
394 | default: c = 0;
395 | }
396 | if (c == 0) {
397 | raise_errmsg("Invalid \\escape", pystr, end - 2);
398 | goto bail;
399 | }
400 | }
401 | else {
402 | c = 0;
403 | next++;
404 | end = next + 4;
405 | if (end >= len) {
406 | raise_errmsg("Invalid \\uXXXX escape", pystr, next - 1);
407 | goto bail;
408 | }
409 | /* Decode 4 hex digits */
410 | for (; next < end; next++) {
411 | Py_UNICODE digit = buf[next];
412 | c <<= 4;
413 | switch (digit) {
414 | case '0': case '1': case '2': case '3': case '4':
415 | case '5': case '6': case '7': case '8': case '9':
416 | c |= (digit - '0'); break;
417 | case 'a': case 'b': case 'c': case 'd': case 'e':
418 | case 'f':
419 | c |= (digit - 'a' + 10); break;
420 | case 'A': case 'B': case 'C': case 'D': case 'E':
421 | case 'F':
422 | c |= (digit - 'A' + 10); break;
423 | default:
424 | raise_errmsg("Invalid \\uXXXX escape", pystr, end - 5);
425 | goto bail;
426 | }
427 | }
428 | #ifdef Py_UNICODE_WIDE
429 | /* Surrogate pair */
430 | if ((c & 0xfc00) == 0xd800) {
431 | Py_UNICODE c2 = 0;
432 | if (end + 6 >= len) {
433 | raise_errmsg("Unpaired high surrogate", pystr, end - 5);
434 | goto bail;
435 | }
436 | if (buf[next++] != '\\' || buf[next++] != 'u') {
437 | raise_errmsg("Unpaired high surrogate", pystr, end - 5);
438 | goto bail;
439 | }
440 | end += 6;
441 | /* Decode 4 hex digits */
442 | for (; next < end; next++) {
443 | Py_UNICODE digit = buf[next];
444 | c2 <<= 4;
445 | switch (digit) {
446 | case '0': case '1': case '2': case '3': case '4':
447 | case '5': case '6': case '7': case '8': case '9':
448 | c2 |= (digit - '0'); break;
449 | case 'a': case 'b': case 'c': case 'd': case 'e':
450 | case 'f':
451 | c2 |= (digit - 'a' + 10); break;
452 | case 'A': case 'B': case 'C': case 'D': case 'E':
453 | case 'F':
454 | c2 |= (digit - 'A' + 10); break;
455 | default:
456 | raise_errmsg("Invalid \\uXXXX escape", pystr, end - 5);
457 | goto bail;
458 | }
459 | }
460 | if ((c2 & 0xfc00) != 0xdc00) {
461 | raise_errmsg("Unpaired high surrogate", pystr, end - 5);
462 | goto bail;
463 | }
464 | c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00));
465 | }
466 | else if ((c & 0xfc00) == 0xdc00) {
467 | raise_errmsg("Unpaired low surrogate", pystr, end - 5);
468 | goto bail;
469 | }
470 | #endif
471 | }
472 | APPEND_OLD_CHUNKif (chunk != ((void*)0)) { if (chunks == ((void*)0)) { chunks = PyList_New(0); if (chunks == ((void*)0)) { goto bail; } } if (PyList_Append(chunks, chunk)) { do { if (_Py_RefTotal-- , -- ((PyObject*)(chunk))->ob_refcnt != 0) { if (((PyObject*)chunk )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 472, (PyObject *)(chunk)); } else _Py_Dealloc((PyObject *)( chunk)); } while (0); goto bail; } do { if (chunk) { PyObject *_py_tmp = (PyObject *)(chunk); (chunk) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 472, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0); }
473 | chunk = PyUnicode_FromUnicodePyUnicodeUCS2_FromUnicode(&c, 1);
474 | if (chunk == NULL((void*)0)) {
475 | goto bail;
476 | }
477 | }
478 |
479 | if (chunks == NULL((void*)0)) {
480 | if (chunk != NULL((void*)0))
481 | rval = chunk;
482 | else
483 | rval = PyUnicode_FromStringAndSizePyUnicodeUCS2_FromStringAndSize("", 0);
484 | }
485 | else {
486 | APPEND_OLD_CHUNKif (chunk != ((void*)0)) { if (chunks == ((void*)0)) { chunks = PyList_New(0); if (chunks == ((void*)0)) { goto bail; } } if (PyList_Append(chunks, chunk)) { do { if (_Py_RefTotal-- , -- ((PyObject*)(chunk))->ob_refcnt != 0) { if (((PyObject*)chunk )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 486, (PyObject *)(chunk)); } else _Py_Dealloc((PyObject *)( chunk)); } while (0); goto bail; } do { if (chunk) { PyObject *_py_tmp = (PyObject *)(chunk); (chunk) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 486, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0); }
487 | rval = join_list_unicode(chunks);
488 | if (rval == NULL((void*)0)) {
489 | goto bail;
490 | }
491 | Py_CLEAR(chunks)do { if (chunks) { PyObject *_py_tmp = (PyObject *)(chunks); ( chunks) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject* )(_py_tmp))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)-> ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 491, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
492 | }
493 |
494 | *next_end_ptr = end;
495 | return rval;
496 | bail:
497 | *next_end_ptr = -1;
498 | Py_XDECREF(chunks)do { if ((chunks) == ((void*)0)) ; else do { if (_Py_RefTotal -- , --((PyObject*)(chunks))->ob_refcnt != 0) { if (((PyObject *)chunks)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 498, (PyObject *)(chunks)); } else _Py_Dealloc((PyObject *) (chunks)); } while (0); } while (0);
499 | Py_XDECREF(chunk)do { if ((chunk) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(chunk))->ob_refcnt != 0) { if (((PyObject *)chunk)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 499, (PyObject *)(chunk)); } else _Py_Dealloc((PyObject *)( chunk)); } while (0); } while (0);
500 | return NULL((void*)0);
501 | }
502 |
503 | PyDoc_STRVAR(pydoc_scanstring,static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
504 | "scanstring(string, end, strict=True) -> (string, end)\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
505 | "\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
506 | "Scan the string s for a JSON string. End is the index of the\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
507 | "character in s after the quote that started the JSON string.\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
508 | "Unescapes all valid JSON string escape sequences and raises ValueError\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
509 | "on attempt to decode an invalid string. If strict is False then literal\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
510 | "control characters are allowed in the string.\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
511 | "\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
512 | "Returns a tuple of the decoded string and the index of the character in s\n"static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
513 | "after the end quote."static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote."
514 | )static char pydoc_scanstring[] = "scanstring(string, end, strict=True) -> (string, end)\n" "\n" "Scan the string s for a JSON string. End is the index of the\n" "character in s after the quote that started the JSON string.\n" "Unescapes all valid JSON string escape sequences and raises ValueError\n" "on attempt to decode an invalid string. If strict is False then literal\n" "control characters are allowed in the string.\n" "\n" "Returns a tuple of the decoded string and the index of the character in s\n" "after the end quote.";
515 |
516 | static PyObject *
517 | py_scanstring(PyObject* self UNUSED__attribute__((__unused__)), PyObject *args)
518 | {
519 | PyObject *pystr;
520 | PyObject *rval;
521 | Py_ssize_t end;
522 | Py_ssize_t next_end = -1;
523 | int strict = 1;
524 | if (!PyArg_ParseTuple(args, "OO&|i:scanstring", &pystr, _convertPyInt_AsSsize_t, &end, &strict)) {
525 | return NULL((void*)0);
526 | }
527 | if (PyUnicode_Check(pystr)((((((PyObject*)(pystr))->ob_type))->tp_flags & ((1L <<28))) != 0)) {
528 | rval = scanstring_unicode(pystr, end, strict, &next_end);
529 | }
530 | else {
531 | PyErr_Format(PyExc_TypeError,
532 | "first argument must be a string, not %.80s",
533 | Py_TYPE(pystr)(((PyObject*)(pystr))->ob_type)->tp_name);
534 | return NULL((void*)0);
535 | }
536 | return _build_rval_index_tuple(rval, next_end);
537 | }
538 |
539 | PyDoc_STRVAR(pydoc_encode_basestring_ascii,static char pydoc_encode_basestring_ascii[] = "encode_basestring_ascii(string) -> string\n" "\n" "Return an ASCII-only JSON representation of a Python string"
540 | "encode_basestring_ascii(string) -> string\n"static char pydoc_encode_basestring_ascii[] = "encode_basestring_ascii(string) -> string\n" "\n" "Return an ASCII-only JSON representation of a Python string"
541 | "\n"static char pydoc_encode_basestring_ascii[] = "encode_basestring_ascii(string) -> string\n" "\n" "Return an ASCII-only JSON representation of a Python string"
542 | "Return an ASCII-only JSON representation of a Python string"static char pydoc_encode_basestring_ascii[] = "encode_basestring_ascii(string) -> string\n" "\n" "Return an ASCII-only JSON representation of a Python string"
543 | )static char pydoc_encode_basestring_ascii[] = "encode_basestring_ascii(string) -> string\n" "\n" "Return an ASCII-only JSON representation of a Python string";
544 |
545 | static PyObject *
546 | py_encode_basestring_ascii(PyObject* self UNUSED__attribute__((__unused__)), PyObject *pystr)
547 | {
548 | PyObject *rval;
549 | /* Return an ASCII-only JSON representation of a Python string */
550 | /* METH_O */
551 | if (PyUnicode_Check(pystr)((((((PyObject*)(pystr))->ob_type))->tp_flags & ((1L <<28))) != 0)) {
552 | rval = ascii_escape_unicode(pystr);
553 | }
554 | else {
555 | PyErr_Format(PyExc_TypeError,
556 | "first argument must be a string, not %.80s",
557 | Py_TYPE(pystr)(((PyObject*)(pystr))->ob_type)->tp_name);
558 | return NULL((void*)0);
559 | }
560 | return rval;
561 | }
562 |
563 | static void
564 | scanner_dealloc(PyObject *self)
565 | {
566 | /* Deallocate scanner object */
567 | scanner_clear(self);
568 | Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free(self);
569 | }
570 |
571 | static int
572 | scanner_traverse(PyObject *self, visitproc visit, void *arg)
573 | {
574 | PyScannerObject *s;
575 | assert(PyScanner_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyScannerType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyScannerType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 575, "PyScanner_Check(self)") : (void)0);
576 | s = (PyScannerObject *)self;
577 | Py_VISIT(s->strict)do { if (s->strict) { int vret = visit((PyObject *)(s-> strict), arg); if (vret) return vret; } } while (0);
578 | Py_VISIT(s->object_hook)do { if (s->object_hook) { int vret = visit((PyObject *)(s ->object_hook), arg); if (vret) return vret; } } while (0);
579 | Py_VISIT(s->object_pairs_hook)do { if (s->object_pairs_hook) { int vret = visit((PyObject *)(s->object_pairs_hook), arg); if (vret) return vret; } } while (0);
580 | Py_VISIT(s->parse_float)do { if (s->parse_float) { int vret = visit((PyObject *)(s ->parse_float), arg); if (vret) return vret; } } while (0);
581 | Py_VISIT(s->parse_int)do { if (s->parse_int) { int vret = visit((PyObject *)(s-> parse_int), arg); if (vret) return vret; } } while (0);
582 | Py_VISIT(s->parse_constant)do { if (s->parse_constant) { int vret = visit((PyObject * )(s->parse_constant), arg); if (vret) return vret; } } while (0);
583 | return 0;
584 | }
585 |
586 | static int
587 | scanner_clear(PyObject *self)
588 | {
589 | PyScannerObject *s;
590 | assert(PyScanner_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyScannerType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyScannerType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 590, "PyScanner_Check(self)") : (void)0);
591 | s = (PyScannerObject *)self;
592 | Py_CLEAR(s->strict)do { if (s->strict) { PyObject *_py_tmp = (PyObject *)(s-> strict); (s->strict) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 592, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
593 | Py_CLEAR(s->object_hook)do { if (s->object_hook) { PyObject *_py_tmp = (PyObject * )(s->object_hook); (s->object_hook) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 593, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
594 | Py_CLEAR(s->object_pairs_hook)do { if (s->object_pairs_hook) { PyObject *_py_tmp = (PyObject *)(s->object_pairs_hook); (s->object_pairs_hook) = ((void *)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))-> ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 594, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
595 | Py_CLEAR(s->parse_float)do { if (s->parse_float) { PyObject *_py_tmp = (PyObject * )(s->parse_float); (s->parse_float) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 595, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
596 | Py_CLEAR(s->parse_int)do { if (s->parse_int) { PyObject *_py_tmp = (PyObject *)( s->parse_int); (s->parse_int) = ((void*)0); do { if (_Py_RefTotal -- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 596, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
597 | Py_CLEAR(s->parse_constant)do { if (s->parse_constant) { PyObject *_py_tmp = (PyObject *)(s->parse_constant); (s->parse_constant) = ((void*)0 ); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 597, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
598 | Py_CLEAR(s->memo)do { if (s->memo) { PyObject *_py_tmp = (PyObject *)(s-> memo); (s->memo) = ((void*)0); do { if (_Py_RefTotal-- , -- ((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject*) _py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 598, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
599 | return 0;
600 | }
601 |
602 | static PyObject *
603 | _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr) {
604 | /* Read a JSON object from PyUnicode pystr.
605 | idx is the index of the first character after the opening curly brace.
606 | *next_idx_ptr is a return-by-reference index to the first character after
607 | the closing curly brace.
608 |
609 | Returns a new PyObject (usually a dict, but object_hook can change that)
610 | */
611 | Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 611, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->str));
612 | Py_ssize_t end_idx = PyUnicode_GET_SIZE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 612, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->length)) - 1;
613 | PyObject *val = NULL((void*)0);
614 | PyObject *rval = NULL((void*)0);
615 | PyObject *key = NULL((void*)0);
616 | int strict = PyObject_IsTrue(s->strict);
617 | int has_pairs_hook = (s->object_pairs_hook != Py_None(&_Py_NoneStruct));
618 | Py_ssize_t next_idx;
619 |
620 | if (has_pairs_hook)
621 | rval = PyList_New(0);
622 | else
623 | rval = PyDict_New();
624 | if (rval == NULL((void*)0))
625 | return NULL((void*)0);
626 |
627 | /* skip whitespace after { */
628 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
629 |
630 | /* only loop if the object is non-empty */
631 | if (idx <= end_idx && str[idx] != '}') {
632 | while (idx <= end_idx) {
633 | PyObject *memokey;
634 |
635 | /* read key */
636 | if (str[idx] != '"') {
637 | raise_errmsg("Expecting property name", pystr, idx);
638 | goto bail;
639 | }
640 | key = scanstring_unicode(pystr, idx + 1, strict, &next_idx);
641 | if (key == NULL((void*)0))
642 | goto bail;
643 | memokey = PyDict_GetItem(s->memo, key);
644 | if (memokey != NULL((void*)0)) {
645 | Py_INCREF(memokey)( _Py_RefTotal++ , ((PyObject*)(memokey))->ob_refcnt++);
646 | Py_DECREF(key)do { if (_Py_RefTotal-- , --((PyObject*)(key))->ob_refcnt != 0) { if (((PyObject*)key)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 646, (PyObject *)(key)); } else _Py_Dealloc((PyObject *)(key)); } while (0);
647 | key = memokey;
648 | }
649 | else {
650 | if (PyDict_SetItem(s->memo, key, key) < 0)
651 | goto bail;
652 | }
653 | idx = next_idx;
654 |
655 | /* skip whitespace between key and : delimiter, read :, skip whitespace */
656 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
657 | if (idx > end_idx || str[idx] != ':') {
658 | raise_errmsg("Expecting : delimiter", pystr, idx);
659 | goto bail;
660 | }
661 | idx++;
662 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
663 |
664 | /* read any JSON term */
665 | val = scan_once_unicode(s, pystr, idx, &next_idx);
666 | if (val == NULL((void*)0))
667 | goto bail;
668 |
669 | if (has_pairs_hook) {
670 | PyObject *item = PyTuple_Pack(2, key, val);
671 | if (item == NULL((void*)0))
672 | goto bail;
673 | Py_CLEAR(key)do { if (key) { PyObject *_py_tmp = (PyObject *)(key); (key) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 673, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
674 | Py_CLEAR(val)do { if (val) { PyObject *_py_tmp = (PyObject *)(val); (val) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 674, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
675 | if (PyList_Append(rval, item) == -1) {
676 | Py_DECREF(item)do { if (_Py_RefTotal-- , --((PyObject*)(item))->ob_refcnt != 0) { if (((PyObject*)item)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 676, (PyObject *)(item)); } else _Py_Dealloc((PyObject *)(item)); } while ( 0);
677 | goto bail;
678 | }
679 | Py_DECREF(item)do { if (_Py_RefTotal-- , --((PyObject*)(item))->ob_refcnt != 0) { if (((PyObject*)item)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 679, (PyObject *)(item)); } else _Py_Dealloc((PyObject *)(item)); } while ( 0);
680 | }
681 | else {
682 | if (PyDict_SetItem(rval, key, val) < 0)
683 | goto bail;
684 | Py_CLEAR(key)do { if (key) { PyObject *_py_tmp = (PyObject *)(key); (key) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 684, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
685 | Py_CLEAR(val)do { if (val) { PyObject *_py_tmp = (PyObject *)(val); (val) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 685, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
686 | }
687 | idx = next_idx;
688 |
689 | /* skip whitespace before } or , */
690 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
691 |
692 | /* bail if the object is closed or we didn't get the , delimiter */
693 | if (idx > end_idx) break;
694 | if (str[idx] == '}') {
695 | break;
696 | }
697 | else if (str[idx] != ',') {
698 | raise_errmsg("Expecting , delimiter", pystr, idx);
699 | goto bail;
700 | }
701 | idx++;
702 |
703 | /* skip whitespace after , delimiter */
704 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
705 | }
706 | }
707 |
708 | /* verify that idx < end_idx, str[idx] should be '}' */
709 | if (idx > end_idx || str[idx] != '}') {
710 | raise_errmsg("Expecting object", pystr, end_idx);
711 | goto bail;
712 | }
713 |
714 | *next_idx_ptr = idx + 1;
715 |
716 | if (has_pairs_hook) {
717 | val = PyObject_CallFunctionObjArgs(s->object_pairs_hook, rval, NULL((void*)0));
718 | Py_DECREF(rval)do { if (_Py_RefTotal-- , --((PyObject*)(rval))->ob_refcnt != 0) { if (((PyObject*)rval)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 718, (PyObject *)(rval)); } else _Py_Dealloc((PyObject *)(rval)); } while ( 0);
719 | return val;
720 | }
721 |
722 | /* if object_hook is not None: rval = object_hook(rval) */
723 | if (s->object_hook != Py_None(&_Py_NoneStruct)) {
724 | val = PyObject_CallFunctionObjArgs(s->object_hook, rval, NULL((void*)0));
725 | Py_DECREF(rval)do { if (_Py_RefTotal-- , --((PyObject*)(rval))->ob_refcnt != 0) { if (((PyObject*)rval)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 725, (PyObject *)(rval)); } else _Py_Dealloc((PyObject *)(rval)); } while ( 0);
726 | return val;
727 | }
728 | return rval;
729 | bail:
730 | Py_XDECREF(key)do { if ((key) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(key))->ob_refcnt != 0) { if (((PyObject*)key )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 730, (PyObject *)(key)); } else _Py_Dealloc((PyObject *)(key )); } while (0); } while (0);
731 | Py_XDECREF(val)do { if ((val) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(val))->ob_refcnt != 0) { if (((PyObject*)val )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 731, (PyObject *)(val)); } else _Py_Dealloc((PyObject *)(val )); } while (0); } while (0);
732 | Py_XDECREF(rval)do { if ((rval) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(rval))->ob_refcnt != 0) { if (((PyObject *)rval)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 732, (PyObject *)(rval)); } else _Py_Dealloc((PyObject *)(rval )); } while (0); } while (0);
733 | return NULL((void*)0);
734 | }
735 |
736 | static PyObject *
737 | _parse_array_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr) {
738 | /* Read a JSON array from PyString pystr.
739 | idx is the index of the first character after the opening brace.
740 | *next_idx_ptr is a return-by-reference index to the first character after
741 | the closing brace.
742 |
743 | Returns a new PyList
744 | */
745 | Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 745, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->str));
746 | Py_ssize_t end_idx = PyUnicode_GET_SIZE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 746, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->length)) - 1;
747 | PyObject *val = NULL((void*)0);
748 | PyObject *rval = PyList_New(0);
749 | Py_ssize_t next_idx;
750 | if (rval == NULL((void*)0))
751 | return NULL((void*)0);
752 |
753 | /* skip whitespace after [ */
754 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
755 |
756 | /* only loop if the array is non-empty */
757 | if (idx <= end_idx && str[idx] != ']') {
758 | while (idx <= end_idx) {
759 |
760 | /* read any JSON term */
761 | val = scan_once_unicode(s, pystr, idx, &next_idx);
762 | if (val == NULL((void*)0))
763 | goto bail;
764 |
765 | if (PyList_Append(rval, val) == -1)
766 | goto bail;
767 |
768 | Py_CLEAR(val)do { if (val) { PyObject *_py_tmp = (PyObject *)(val); (val) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 768, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
769 | idx = next_idx;
770 |
771 | /* skip whitespace between term and , */
772 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
773 |
774 | /* bail if the array is closed or we didn't get the , delimiter */
775 | if (idx > end_idx) break;
776 | if (str[idx] == ']') {
777 | break;
778 | }
779 | else if (str[idx] != ',') {
780 | raise_errmsg("Expecting , delimiter", pystr, idx);
781 | goto bail;
782 | }
783 | idx++;
784 |
785 | /* skip whitespace after , */
786 | while (idx <= end_idx && IS_WHITESPACE(str[idx])(((str[idx]) == ' ') || ((str[idx]) == '\t') || ((str[idx]) == '\n') || ((str[idx]) == '\r'))) idx++;
787 | }
788 | }
789 |
790 | /* verify that idx < end_idx, str[idx] should be ']' */
791 | if (idx > end_idx || str[idx] != ']') {
792 | raise_errmsg("Expecting object", pystr, end_idx);
793 | goto bail;
794 | }
795 | *next_idx_ptr = idx + 1;
796 | return rval;
797 | bail:
798 | Py_XDECREF(val)do { if ((val) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(val))->ob_refcnt != 0) { if (((PyObject*)val )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 798, (PyObject *)(val)); } else _Py_Dealloc((PyObject *)(val )); } while (0); } while (0);
799 | Py_DECREF(rval)do { if (_Py_RefTotal-- , --((PyObject*)(rval))->ob_refcnt != 0) { if (((PyObject*)rval)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 799, (PyObject *)(rval)); } else _Py_Dealloc((PyObject *)(rval)); } while ( 0);
800 | return NULL((void*)0);
801 | }
802 |
803 | static PyObject *
804 | _parse_constant(PyScannerObject *s, char *constant, Py_ssize_t idx, Py_ssize_t *next_idx_ptr) {
805 | /* Read a JSON constant from PyString pystr.
806 | constant is the constant string that was found
807 | ("NaN", "Infinity", "-Infinity").
808 | idx is the index of the first character of the constant
809 | *next_idx_ptr is a return-by-reference index to the first character after
810 | the constant.
811 |
812 | Returns the result of parse_constant
813 | */
814 | PyObject *cstr;
815 | PyObject *rval;
816 | /* constant is "NaN", "Infinity", or "-Infinity" */
817 | cstr = PyUnicode_InternFromString(constant);
818 | if (cstr == NULL((void*)0))
819 | return NULL((void*)0);
820 |
821 | /* rval = parse_constant(constant) */
822 | rval = PyObject_CallFunctionObjArgs(s->parse_constant, cstr, NULL((void*)0));
823 | idx += PyUnicode_GET_SIZE(cstr)((__builtin_expect(!(((((((PyObject*)(cstr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 823, "PyUnicode_Check(cstr)" ) : (void)0),(((PyUnicodeObject *)(cstr))->length));
824 | Py_DECREF(cstr)do { if (_Py_RefTotal-- , --((PyObject*)(cstr))->ob_refcnt != 0) { if (((PyObject*)cstr)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 824, (PyObject *)(cstr)); } else _Py_Dealloc((PyObject *)(cstr)); } while ( 0);
825 | *next_idx_ptr = idx;
826 | return rval;
827 | }
828 |
829 | static PyObject *
830 | _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_ssize_t *next_idx_ptr) {
831 | /* Read a JSON number from PyUnicode pystr.
832 | idx is the index of the first character of the number
833 | *next_idx_ptr is a return-by-reference index to the first character after
834 | the number.
835 |
836 | Returns a new PyObject representation of that number:
837 | PyInt, PyLong, or PyFloat.
838 | May return other types if parse_int or parse_float are set
839 | */
840 | Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 840, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->str));
841 | Py_ssize_t end_idx = PyUnicode_GET_SIZE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 841, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->length)) - 1;
842 | Py_ssize_t idx = start;
843 | int is_float = 0;
844 | PyObject *rval;
845 | PyObject *numstr;
846 |
847 | /* read a sign if it's there, make sure it's not the end of the string */
848 | if (str[idx] == '-') {
849 | idx++;
850 | if (idx > end_idx) {
851 | PyErr_SetNone(PyExc_StopIteration);
852 | return NULL((void*)0);
853 | }
854 | }
855 |
856 | /* read as many integer digits as we find as long as it doesn't start with 0 */
857 | if (str[idx] >= '1' && str[idx] <= '9') {
858 | idx++;
859 | while (idx <= end_idx && str[idx] >= '0' && str[idx] <= '9') idx++;
860 | }
861 | /* if it starts with 0 we only expect one integer digit */
862 | else if (str[idx] == '0') {
863 | idx++;
864 | }
865 | /* no integer digits, error */
866 | else {
867 | PyErr_SetNone(PyExc_StopIteration);
868 | return NULL((void*)0);
869 | }
870 |
871 | /* if the next char is '.' followed by a digit then read all float digits */
872 | if (idx < end_idx && str[idx] == '.' && str[idx + 1] >= '0' && str[idx + 1] <= '9') {
873 | is_float = 1;
874 | idx += 2;
875 | while (idx <= end_idx && str[idx] >= '0' && str[idx] <= '9') idx++;
876 | }
877 |
878 | /* if the next char is 'e' or 'E' then maybe read the exponent (or backtrack) */
879 | if (idx < end_idx && (str[idx] == 'e' || str[idx] == 'E')) {
880 | Py_ssize_t e_start = idx;
881 | idx++;
882 |
883 | /* read an exponent sign if present */
884 | if (idx < end_idx && (str[idx] == '-' || str[idx] == '+')) idx++;
885 |
886 | /* read all digits */
887 | while (idx <= end_idx && str[idx] >= '0' && str[idx] <= '9') idx++;
888 |
889 | /* if we got a digit, then parse as float. if not, backtrack */
890 | if (str[idx - 1] >= '0' && str[idx - 1] <= '9') {
891 | is_float = 1;
892 | }
893 | else {
894 | idx = e_start;
895 | }
896 | }
897 |
898 | /* copy the section we determined to be a number */
899 | numstr = PyUnicode_FromUnicodePyUnicodeUCS2_FromUnicode(&str[start], idx - start);
900 | if (numstr == NULL((void*)0))
901 | return NULL((void*)0);
902 | if (is_float) {
903 | /* parse as a float using a fast path if available, otherwise call user defined method */
904 | if (s->parse_float != (PyObject *)&PyFloat_Type) {
905 | rval = PyObject_CallFunctionObjArgs(s->parse_float, numstr, NULL((void*)0));
906 | }
907 | else {
908 | rval = PyFloat_FromString(numstr);
909 | }
910 | }
911 | else {
912 | /* no fast path for unicode -> int, just call */
913 | rval = PyObject_CallFunctionObjArgs(s->parse_int, numstr, NULL((void*)0));
914 | }
915 | Py_DECREF(numstr)do { if (_Py_RefTotal-- , --((PyObject*)(numstr))->ob_refcnt != 0) { if (((PyObject*)numstr)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 915, (PyObject *)(numstr)); } else _Py_Dealloc((PyObject *)(numstr)); } while (0);
916 | *next_idx_ptr = idx;
917 | return rval;
918 | }
919 |
920 | static PyObject *
921 | scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *next_idx_ptr)
922 | {
923 | /* Read one JSON term (of any kind) from PyUnicode pystr.
924 | idx is the index of the first character of the term
925 | *next_idx_ptr is a return-by-reference index to the first character after
926 | the number.
927 |
928 | Returns a new PyObject representation of the term.
929 | */
930 | Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 930, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->str));
931 | Py_ssize_t length = PyUnicode_GET_SIZE(pystr)((__builtin_expect(!(((((((PyObject*)(pystr))->ob_type))-> tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__ , "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 931, "PyUnicode_Check(pystr)" ) : (void)0),(((PyUnicodeObject *)(pystr))->length));
932 | if (idx >= length) {
933 | PyErr_SetNone(PyExc_StopIteration);
934 | return NULL((void*)0);
935 | }
936 | switch (str[idx]) {
937 | case '"':
938 | /* string */
939 | return scanstring_unicode(pystr, idx + 1,
940 | PyObject_IsTrue(s->strict),
941 | next_idx_ptr);
942 | case '{':
943 | /* object */
944 | return _parse_object_unicode(s, pystr, idx + 1, next_idx_ptr);
945 | case '[':
946 | /* array */
947 | return _parse_array_unicode(s, pystr, idx + 1, next_idx_ptr);
948 | case 'n':
949 | /* null */
950 | if ((idx + 3 < length) && str[idx + 1] == 'u' && str[idx + 2] == 'l' && str[idx + 3] == 'l') {
951 | Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt ++);
952 | *next_idx_ptr = idx + 4;
953 | return Py_None(&_Py_NoneStruct);
954 | }
955 | break;
956 | case 't':
957 | /* true */
958 | if ((idx + 3 < length) && str[idx + 1] == 'r' && str[idx + 2] == 'u' && str[idx + 3] == 'e') {
959 | Py_INCREF(Py_True)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct )))->ob_refcnt++);
960 | *next_idx_ptr = idx + 4;
961 | return Py_True((PyObject *) &_Py_TrueStruct);
962 | }
963 | break;
964 | case 'f':
965 | /* false */
966 | if ((idx + 4 < length) && str[idx + 1] == 'a' && str[idx + 2] == 'l' && str[idx + 3] == 's' && str[idx + 4] == 'e') {
967 | Py_INCREF(Py_False)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_FalseStruct )))->ob_refcnt++);
968 | *next_idx_ptr = idx + 5;
969 | return Py_False((PyObject *) &_Py_FalseStruct);
970 | }
971 | break;
972 | case 'N':
973 | /* NaN */
974 | if ((idx + 2 < length) && str[idx + 1] == 'a' && str[idx + 2] == 'N') {
975 | return _parse_constant(s, "NaN", idx, next_idx_ptr);
976 | }
977 | break;
978 | case 'I':
979 | /* Infinity */
980 | if ((idx + 7 < length) && str[idx + 1] == 'n' && str[idx + 2] == 'f' && str[idx + 3] == 'i' && str[idx + 4] == 'n' && str[idx + 5] == 'i' && str[idx + 6] == 't' && str[idx + 7] == 'y') {
981 | return _parse_constant(s, "Infinity", idx, next_idx_ptr);
982 | }
983 | break;
984 | case '-':
985 | /* -Infinity */
986 | if ((idx + 8 < length) && str[idx + 1] == 'I' && str[idx + 2] == 'n' && str[idx + 3] == 'f' && str[idx + 4] == 'i' && str[idx + 5] == 'n' && str[idx + 6] == 'i' && str[idx + 7] == 't' && str[idx + 8] == 'y') {
987 | return _parse_constant(s, "-Infinity", idx, next_idx_ptr);
988 | }
989 | break;
990 | }
991 | /* Didn't find a string, object, array, or named constant. Look for a number. */
992 | return _match_number_unicode(s, pystr, idx, next_idx_ptr);
993 | }
994 |
995 | static PyObject *
996 | scanner_call(PyObject *self, PyObject *args, PyObject *kwds)
997 | {
998 | /* Python callable interface to scan_once_{str,unicode} */
999 | PyObject *pystr;
1000 | PyObject *rval;
1001 | Py_ssize_t idx;
1002 | Py_ssize_t next_idx = -1;
1003 | static char *kwlist[] = {"string", "idx", NULL((void*)0)};
1004 | PyScannerObject *s;
1005 | assert(PyScanner_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyScannerType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyScannerType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1005, "PyScanner_Check(self)") : (void)0);
1006 | s = (PyScannerObject *)self;
1007 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&:scan_once", kwlist, &pystr, _convertPyInt_AsSsize_t, &idx))
1008 | return NULL((void*)0);
1009 |
1010 | if (PyUnicode_Check(pystr)((((((PyObject*)(pystr))->ob_type))->tp_flags & ((1L <<28))) != 0)) {
1011 | rval = scan_once_unicode(s, pystr, idx, &next_idx);
1012 | }
1013 | else {
1014 | PyErr_Format(PyExc_TypeError,
1015 | "first argument must be a string, not %.80s",
1016 | Py_TYPE(pystr)(((PyObject*)(pystr))->ob_type)->tp_name);
1017 | return NULL((void*)0);
1018 | }
1019 | PyDict_Clear(s->memo);
1020 | if (rval == NULL((void*)0))
1021 | return NULL((void*)0);
1022 | return _build_rval_index_tuple(rval, next_idx);
1023 | }
1024 |
1025 | static PyObject *
1026 | scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1027 | {
1028 | PyScannerObject *s;
1029 | s = (PyScannerObject *)type->tp_alloc(type, 0);
1030 | if (s != NULL((void*)0)) {
1031 | s->strict = NULL((void*)0);
1032 | s->object_hook = NULL((void*)0);
1033 | s->object_pairs_hook = NULL((void*)0);
1034 | s->parse_float = NULL((void*)0);
1035 | s->parse_int = NULL((void*)0);
1036 | s->parse_constant = NULL((void*)0);
1037 | }
1038 | return (PyObject *)s;
1039 | }
1040 |
1041 | static int
1042 | scanner_init(PyObject *self, PyObject *args, PyObject *kwds)
1043 | {
1044 | /* Initialize Scanner object */
1045 | PyObject *ctx;
1046 | static char *kwlist[] = {"context", NULL((void*)0)};
1047 | PyScannerObject *s;
1048 |
1049 | assert(PyScanner_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyScannerType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyScannerType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1049, "PyScanner_Check(self)") : (void)0);
1050 | s = (PyScannerObject *)self;
1051 |
1052 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:make_scanner", kwlist, &ctx))
1053 | return -1;
1054 |
1055 | if (s->memo == NULL((void*)0)) {
1056 | s->memo = PyDict_New();
1057 | if (s->memo == NULL((void*)0))
1058 | goto bail;
1059 | }
1060 |
1061 | /* All of these will fail "gracefully" so we don't need to verify them */
1062 | s->strict = PyObject_GetAttrString(ctx, "strict");
1063 | if (s->strict == NULL((void*)0))
1064 | goto bail;
1065 | s->object_hook = PyObject_GetAttrString(ctx, "object_hook");
1066 | if (s->object_hook == NULL((void*)0))
1067 | goto bail;
1068 | s->object_pairs_hook = PyObject_GetAttrString(ctx, "object_pairs_hook");
1069 | if (s->object_pairs_hook == NULL((void*)0))
1070 | goto bail;
1071 | s->parse_float = PyObject_GetAttrString(ctx, "parse_float");
1072 | if (s->parse_float == NULL((void*)0))
1073 | goto bail;
1074 | s->parse_int = PyObject_GetAttrString(ctx, "parse_int");
1075 | if (s->parse_int == NULL((void*)0))
1076 | goto bail;
1077 | s->parse_constant = PyObject_GetAttrString(ctx, "parse_constant");
1078 | if (s->parse_constant == NULL((void*)0))
1079 | goto bail;
1080 |
1081 | return 0;
1082 |
1083 | bail:
1084 | Py_CLEAR(s->strict)do { if (s->strict) { PyObject *_py_tmp = (PyObject *)(s-> strict); (s->strict) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1084, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1085 | Py_CLEAR(s->object_hook)do { if (s->object_hook) { PyObject *_py_tmp = (PyObject * )(s->object_hook); (s->object_hook) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1085, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
1086 | Py_CLEAR(s->object_pairs_hook)do { if (s->object_pairs_hook) { PyObject *_py_tmp = (PyObject *)(s->object_pairs_hook); (s->object_pairs_hook) = ((void *)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))-> ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1086, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1087 | Py_CLEAR(s->parse_float)do { if (s->parse_float) { PyObject *_py_tmp = (PyObject * )(s->parse_float); (s->parse_float) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0 ) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1087, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
1088 | Py_CLEAR(s->parse_int)do { if (s->parse_int) { PyObject *_py_tmp = (PyObject *)( s->parse_int); (s->parse_int) = ((void*)0); do { if (_Py_RefTotal -- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1088, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1089 | Py_CLEAR(s->parse_constant)do { if (s->parse_constant) { PyObject *_py_tmp = (PyObject *)(s->parse_constant); (s->parse_constant) = ((void*)0 ); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1089, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
1090 | return -1;
1091 | }
1092 |
1093 | PyDoc_STRVAR(scanner_doc, "JSON scanner object")static char scanner_doc[] = "JSON scanner object";
1094 |
1095 | static
1096 | PyTypeObject PyScannerType = {
1097 | PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 },
1098 | "_json.Scanner", /* tp_name */
1099 | sizeof(PyScannerObject), /* tp_basicsize */
1100 | 0, /* tp_itemsize */
1101 | scanner_dealloc, /* tp_dealloc */
1102 | 0, /* tp_print */
1103 | 0, /* tp_getattr */
1104 | 0, /* tp_setattr */
1105 | 0, /* tp_compare */
1106 | 0, /* tp_repr */
1107 | 0, /* tp_as_number */
1108 | 0, /* tp_as_sequence */
1109 | 0, /* tp_as_mapping */
1110 | 0, /* tp_hash */
1111 | scanner_call, /* tp_call */
1112 | 0, /* tp_str */
1113 | 0,/* PyObject_GenericGetAttr, */ /* tp_getattro */
1114 | 0,/* PyObject_GenericSetAttr, */ /* tp_setattro */
1115 | 0, /* tp_as_buffer */
1116 | Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_HAVE_GC(1L<<14), /* tp_flags */
1117 | scanner_doc, /* tp_doc */
1118 | scanner_traverse, /* tp_traverse */
1119 | scanner_clear, /* tp_clear */
1120 | 0, /* tp_richcompare */
1121 | 0, /* tp_weaklistoffset */
1122 | 0, /* tp_iter */
1123 | 0, /* tp_iternext */
1124 | 0, /* tp_methods */
1125 | scanner_members, /* tp_members */
1126 | 0, /* tp_getset */
1127 | 0, /* tp_base */
1128 | 0, /* tp_dict */
1129 | 0, /* tp_descr_get */
1130 | 0, /* tp_descr_set */
1131 | 0, /* tp_dictoffset */
1132 | scanner_init, /* tp_init */
1133 | 0,/* PyType_GenericAlloc, */ /* tp_alloc */
1134 | scanner_new, /* tp_new */
1135 | 0,/* PyObject_GC_Del, */ /* tp_free */
1136 | };
1137 |
1138 | static PyObject *
1139 | encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1140 | {
1141 | PyEncoderObject *s;
1142 | s = (PyEncoderObject *)type->tp_alloc(type, 0);
1143 | if (s != NULL((void*)0)) {
1144 | s->markers = NULL((void*)0);
1145 | s->defaultfn = NULL((void*)0);
1146 | s->encoder = NULL((void*)0);
1147 | s->indent = NULL((void*)0);
1148 | s->key_separator = NULL((void*)0);
1149 | s->item_separator = NULL((void*)0);
1150 | s->sort_keys = NULL((void*)0);
1151 | s->skipkeys = NULL((void*)0);
1152 | }
1153 | return (PyObject *)s;
1154 | }
1155 |
1156 | static int
1157 | encoder_init(PyObject *self, PyObject *args, PyObject *kwds)
1158 | {
1159 | /* initialize Encoder object */
1160 | static char *kwlist[] = {"markers", "default", "encoder", "indent", "key_separator", "item_separator", "sort_keys", "skipkeys", "allow_nan", NULL((void*)0)};
1161 |
1162 | PyEncoderObject *s;
1163 | PyObject *markers, *defaultfn, *encoder, *indent, *key_separator;
1164 | PyObject *item_separator, *sort_keys, *skipkeys, *allow_nan;
1165 |
1166 | assert(PyEncoder_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyEncoderType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyEncoderType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1166, "PyEncoder_Check(self)") : (void)0);
1167 | s = (PyEncoderObject *)self;
1168 |
1169 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOOOO:make_encoder", kwlist,
1170 | &markers, &defaultfn, &encoder, &indent, &key_separator, &item_separator,
1171 | &sort_keys, &skipkeys, &allow_nan))
1172 | return -1;
1173 |
1174 | s->markers = markers;
1175 | s->defaultfn = defaultfn;
1176 | s->encoder = encoder;
1177 | s->indent = indent;
1178 | s->key_separator = key_separator;
1179 | s->item_separator = item_separator;
1180 | s->sort_keys = sort_keys;
1181 | s->skipkeys = skipkeys;
1182 | s->fast_encode = (PyCFunction_Check(s->encoder)((((PyObject*)(s->encoder))->ob_type) == &PyCFunction_Type ) && PyCFunction_GetFunction(s->encoder) == (PyCFunction)py_encode_basestring_ascii);
1183 | s->allow_nan = PyObject_IsTrue(allow_nan);
1184 |
1185 | Py_INCREF(s->markers)( _Py_RefTotal++ , ((PyObject*)(s->markers))->ob_refcnt ++);
1186 | Py_INCREF(s->defaultfn)( _Py_RefTotal++ , ((PyObject*)(s->defaultfn))->ob_refcnt ++);
1187 | Py_INCREF(s->encoder)( _Py_RefTotal++ , ((PyObject*)(s->encoder))->ob_refcnt ++);
1188 | Py_INCREF(s->indent)( _Py_RefTotal++ , ((PyObject*)(s->indent))->ob_refcnt++ );
1189 | Py_INCREF(s->key_separator)( _Py_RefTotal++ , ((PyObject*)(s->key_separator))->ob_refcnt ++);
1190 | Py_INCREF(s->item_separator)( _Py_RefTotal++ , ((PyObject*)(s->item_separator))->ob_refcnt ++);
1191 | Py_INCREF(s->sort_keys)( _Py_RefTotal++ , ((PyObject*)(s->sort_keys))->ob_refcnt ++);
1192 | Py_INCREF(s->skipkeys)( _Py_RefTotal++ , ((PyObject*)(s->skipkeys))->ob_refcnt ++);
1193 | return 0;
1194 | }
1195 |
1196 | static PyObject *
1197 | encoder_call(PyObject *self, PyObject *args, PyObject *kwds)
1198 | {
1199 | /* Python callable interface to encode_listencode_obj */
1200 | static char *kwlist[] = {"obj", "_current_indent_level", NULL((void*)0)};
1201 | PyObject *obj;
1202 | PyObject *rval;
1203 | Py_ssize_t indent_level;
1204 | PyEncoderObject *s;
1205 | assert(PyEncoder_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyEncoderType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyEncoderType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1205, "PyEncoder_Check(self)") : (void)0);
1206 | s = (PyEncoderObject *)self;
1207 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&:_iterencode", kwlist,
1208 | &obj, _convertPyInt_AsSsize_t, &indent_level))
1209 | return NULL((void*)0);
1210 | rval = PyList_New(0);
1211 | if (rval == NULL((void*)0))
1212 | return NULL((void*)0);
1213 | if (encoder_listencode_obj(s, rval, obj, indent_level)) {
1214 | Py_DECREF(rval)do { if (_Py_RefTotal-- , --((PyObject*)(rval))->ob_refcnt != 0) { if (((PyObject*)rval)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1214, (PyObject *)(rval)); } else _Py_Dealloc((PyObject *)(rval)); } while ( 0);
1215 | return NULL((void*)0);
1216 | }
1217 | return rval;
1218 | }
1219 |
1220 | static PyObject *
1221 | _encoded_const(PyObject *obj)
1222 | {
1223 | /* Return the JSON string representation of None, True, False */
1224 | if (obj == Py_None(&_Py_NoneStruct)) {
1225 | static PyObject *s_null = NULL((void*)0);
1226 | if (s_null == NULL((void*)0)) {
1227 | s_null = PyUnicode_InternFromString("null");
1228 | }
1229 | Py_INCREF(s_null)( _Py_RefTotal++ , ((PyObject*)(s_null))->ob_refcnt++);
1230 | return s_null;
1231 | }
1232 | else if (obj == Py_True((PyObject *) &_Py_TrueStruct)) {
1233 | static PyObject *s_true = NULL((void*)0);
1234 | if (s_true == NULL((void*)0)) {
1235 | s_true = PyUnicode_InternFromString("true");
1236 | }
1237 | Py_INCREF(s_true)( _Py_RefTotal++ , ((PyObject*)(s_true))->ob_refcnt++);
1238 | return s_true;
1239 | }
1240 | else if (obj == Py_False((PyObject *) &_Py_FalseStruct)) {
1241 | static PyObject *s_false = NULL((void*)0);
1242 | if (s_false == NULL((void*)0)) {
1243 | s_false = PyUnicode_InternFromString("false");
1244 | }
1245 | Py_INCREF(s_false)( _Py_RefTotal++ , ((PyObject*)(s_false))->ob_refcnt++);
1246 | return s_false;
1247 | }
1248 | else {
1249 | PyErr_SetString(PyExc_ValueError, "not a const");
1250 | return NULL((void*)0);
1251 | }
1252 | }
1253 |
1254 | static PyObject *
1255 | encoder_encode_float(PyEncoderObject *s, PyObject *obj)
1256 | {
1257 | /* Return the JSON representation of a PyFloat */
1258 | double i = PyFloat_AS_DOUBLE(obj)(((PyFloatObject *)(obj))->ob_fval);
1259 | if (!Py_IS_FINITE(i)( sizeof (i) == sizeof(float ) ? __inline_isfinitef((float)(i )) : sizeof (i) == sizeof(double) ? __inline_isfinited((double )(i)) : __inline_isfinite ((long double)(i)))) {
1260 | if (!s->allow_nan) {
1261 | PyErr_SetString(PyExc_ValueError, "Out of range float values are not JSON compliant");
1262 | return NULL((void*)0);
1263 | }
1264 | if (i > 0) {
1265 | return PyUnicode_FromStringPyUnicodeUCS2_FromString("Infinity");
1266 | }
1267 | else if (i < 0) {
1268 | return PyUnicode_FromStringPyUnicodeUCS2_FromString("-Infinity");
1269 | }
1270 | else {
1271 | return PyUnicode_FromStringPyUnicodeUCS2_FromString("NaN");
1272 | }
1273 | }
1274 | /* Use a better float format here? */
1275 | return PyObject_Repr(obj);
1276 | }
1277 |
1278 | static PyObject *
1279 | encoder_encode_string(PyEncoderObject *s, PyObject *obj)
1280 | {
1281 | /* Return the JSON representation of a string */
1282 | if (s->fast_encode)
1283 | return py_encode_basestring_ascii(NULL((void*)0), obj);
1284 | else
1285 | return PyObject_CallFunctionObjArgs(s->encoder, obj, NULL((void*)0));
1286 | }
1287 |
1288 | static int
1289 | _steal_list_append(PyObject *lst, PyObject *stolen)
1290 | {
1291 | /* Append stolen and then decrement its reference count */
1292 | int rval = PyList_Append(lst, stolen);
1293 | Py_DECREF(stolen)do { if (_Py_RefTotal-- , --((PyObject*)(stolen))->ob_refcnt != 0) { if (((PyObject*)stolen)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1293, (PyObject *)(stolen)); } else _Py_Dealloc((PyObject *)(stolen)); } while (0);
1294 | return rval;
1295 | }
1296 |
1297 | static int
1298 | encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssize_t indent_level)
1299 | {
1300 | /* Encode Python object obj to a JSON term, rval is a PyList */
1301 | PyObject *newobj;
1302 | int rv;
1303 |
1304 | if (obj == Py_None(&_Py_NoneStruct) || obj == Py_True((PyObject *) &_Py_TrueStruct) || obj == Py_False((PyObject *) &_Py_FalseStruct)) {
1305 | PyObject *cstr = _encoded_const(obj);
1306 | if (cstr == NULL((void*)0))
1307 | return -1;
1308 | return _steal_list_append(rval, cstr);
1309 | }
1310 | else if (PyUnicode_Check(obj)((((((PyObject*)(obj))->ob_type))->tp_flags & ((1L<< 28))) != 0))
1311 | {
1312 | PyObject *encoded = encoder_encode_string(s, obj);
1313 | if (encoded == NULL((void*)0))
1314 | return -1;
1315 | return _steal_list_append(rval, encoded);
1316 | }
1317 | else if (PyLong_Check(obj)((((((PyObject*)(obj))->ob_type))->tp_flags & ((1L<< 24))) != 0)) {
1318 | PyObject *encoded = PyObject_Str(obj);
1319 | if (encoded == NULL((void*)0))
1320 | return -1;
1321 | return _steal_list_append(rval, encoded);
1322 | }
1323 | else if (PyFloat_Check(obj)((((PyObject*)(obj))->ob_type) == (&PyFloat_Type) || PyType_IsSubtype ((((PyObject*)(obj))->ob_type), (&PyFloat_Type)))) {
1324 | PyObject *encoded = encoder_encode_float(s, obj);
1325 | if (encoded == NULL((void*)0))
1326 | return -1;
1327 | return _steal_list_append(rval, encoded);
1328 | }
1329 | else if (PyList_Check(obj)((((((PyObject*)(obj))->ob_type))->tp_flags & ((1L<< 25))) != 0) || PyTuple_Check(obj)((((((PyObject*)(obj))->ob_type))->tp_flags & ((1L<< 26))) != 0)) {
1330 | return encoder_listencode_list(s, rval, obj, indent_level);
1331 | }
1332 | else if (PyDict_Check(obj)((((((PyObject*)(obj))->ob_type))->tp_flags & ((1L<< 29))) != 0)) {
1333 | return encoder_listencode_dict(s, rval, obj, indent_level);
1334 | }
1335 | else {
1336 | PyObject *ident = NULL((void*)0);
1337 | if (s->markers != Py_None(&_Py_NoneStruct)) {
1338 | int has_key;
1339 | ident = PyLong_FromVoidPtr(obj);
1340 | if (ident == NULL((void*)0))
1341 | return -1;
1342 | has_key = PyDict_Contains(s->markers, ident);
1343 | if (has_key) {
1344 | if (has_key != -1)
1345 | PyErr_SetString(PyExc_ValueError, "Circular reference detected");
1346 | Py_DECREF(ident)do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject*)ident)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1346, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *)(ident)); } while (0);
1347 | return -1;
1348 | }
1349 | if (PyDict_SetItem(s->markers, ident, obj)) {
1350 | Py_DECREF(ident)do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject*)ident)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1350, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *)(ident)); } while (0);
1351 | return -1;
1352 | }
1353 | }
1354 | newobj = PyObject_CallFunctionObjArgs(s->defaultfn, obj, NULL((void*)0));
1355 | if (newobj == NULL((void*)0)) {
1356 | Py_XDECREF(ident)do { if ((ident) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject *)ident)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1356, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *) (ident)); } while (0); } while (0);
1357 | return -1;
1358 | }
1359 | rv = encoder_listencode_obj(s, rval, newobj, indent_level);
1360 | Py_DECREF(newobj)do { if (_Py_RefTotal-- , --((PyObject*)(newobj))->ob_refcnt != 0) { if (((PyObject*)newobj)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1360, (PyObject *)(newobj)); } else _Py_Dealloc((PyObject *)(newobj)); } while (0);
1361 | if (rv) {
1362 | Py_XDECREF(ident)do { if ((ident) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject *)ident)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1362, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *) (ident)); } while (0); } while (0);
1363 | return -1;
1364 | }
1365 | if (ident != NULL((void*)0)) {
1366 | if (PyDict_DelItem(s->markers, ident)) {
1367 | Py_XDECREF(ident)do { if ((ident) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject *)ident)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1367, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *) (ident)); } while (0); } while (0);
1368 | return -1;
1369 | }
1370 | Py_XDECREF(ident)do { if ((ident) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject *)ident)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1370, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *) (ident)); } while (0); } while (0);
1371 | }
1372 | return rv;
1373 | }
1374 | }
1375 |
1376 | static int
1377 | encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ssize_t indent_level)
1378 | {
1379 | /* Encode Python dict dct a JSON term, rval is a PyList */
1380 | static PyObject *open_dict = NULL((void*)0);
1381 | static PyObject *close_dict = NULL((void*)0);
1382 | static PyObject *empty_dict = NULL((void*)0);
1383 | PyObject *kstr = NULL((void*)0);
1384 | PyObject *ident = NULL((void*)0);
1385 | PyObject *it = NULL((void*)0);
1386 | PyObject *items;
1387 | PyObject *item = NULL((void*)0);
1388 | int skipkeys;
1389 | Py_ssize_t idx;
1390 |
1391 | if (open_dict == NULL((void*)0) || close_dict == NULL((void*)0) || empty_dict == NULL((void*)0)) {
1392 | open_dict = PyUnicode_InternFromString("{");
1393 | close_dict = PyUnicode_InternFromString("}");
1394 | empty_dict = PyUnicode_InternFromString("{}");
1395 | if (open_dict == NULL((void*)0) || close_dict == NULL((void*)0) || empty_dict == NULL((void*)0))
1396 | return -1;
1397 | }
1398 | if (Py_SIZE(dct)(((PyVarObject*)(dct))->ob_size) == 0)
1399 | return PyList_Append(rval, empty_dict);
1400 |
1401 | if (s->markers != Py_None(&_Py_NoneStruct)) {
1402 | int has_key;
1403 | ident = PyLong_FromVoidPtr(dct);
1404 | if (ident == NULL((void*)0))
1405 | goto bail;
1406 | has_key = PyDict_Contains(s->markers, ident);
1407 | if (has_key) {
1408 | if (has_key != -1)
1409 | PyErr_SetString(PyExc_ValueError, "Circular reference detected");
1410 | goto bail;
1411 | }
1412 | if (PyDict_SetItem(s->markers, ident, dct)) {
1413 | goto bail;
1414 | }
1415 | }
1416 |
1417 | if (PyList_Append(rval, open_dict))
1418 | goto bail;
1419 |
1420 | if (s->indent != Py_None(&_Py_NoneStruct)) {
1421 | /* TODO: DOES NOT RUN */
1422 | indent_level += 1;
1423 | /*
1424 | newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
1425 | separator = _item_separator + newline_indent
1426 | buf += newline_indent
1427 | */
1428 | }
1429 |
1430 | if (PyObject_IsTrue(s->sort_keys)) {
1431 | /* First sort the keys then replace them with (key, value) tuples. */
1432 | Py_ssize_t i, nitems;
1433 | items = PyMapping_Keys(dct);
1434 | if (items == NULL((void*)0))
1435 | goto bail;
1436 | if (!PyList_Check(items)((((((PyObject*)(items))->ob_type))->tp_flags & ((1L <<25))) != 0)) {
1437 | PyErr_SetString(PyExc_ValueError, "keys must return list");
1438 | goto bail;
1439 | }
1440 | if (PyList_Sort(items) < 0)
1441 | goto bail;
1442 | nitems = PyList_GET_SIZE(items)(((PyVarObject*)(items))->ob_size);
1443 | for (i = 0; i < nitems; i++) {
1444 | PyObject *key, *value;
1445 | key = PyList_GET_ITEM(items, i)(((PyListObject *)(items))->ob_item[i]);
1446 | value = PyDict_GetItem(dct, key);
1447 | item = PyTuple_Pack(2, key, value);
1448 | if (item == NULL((void*)0))
1449 | goto bail;
1450 | PyList_SET_ITEM(items, i, item)(((PyListObject *)(items))->ob_item[i] = (item));
1451 | Py_DECREF(key)do { if (_Py_RefTotal-- , --((PyObject*)(key))->ob_refcnt != 0) { if (((PyObject*)key)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1451, (PyObject *)(key)); } else _Py_Dealloc((PyObject *)(key)); } while (0);
1452 | }
1453 | }
1454 | else {
1455 | items = PyMapping_Items(dct);
1456 | }
1457 | if (items == NULL((void*)0))
1458 | goto bail;
1459 | it = PyObject_GetIter(items);
1460 | Py_DECREF(items)do { if (_Py_RefTotal-- , --((PyObject*)(items))->ob_refcnt != 0) { if (((PyObject*)items)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1460, (PyObject *)(items)); } else _Py_Dealloc((PyObject *)(items)); } while (0);
1461 | if (it == NULL((void*)0))
1462 | goto bail;
1463 | skipkeys = PyObject_IsTrue(s->skipkeys);
1464 | idx = 0;
1465 | while ((item = PyIter_Next(it)) != NULL((void*)0)) {
1466 | PyObject *encoded, *key, *value;
1467 | if (!PyTuple_Check(item)((((((PyObject*)(item))->ob_type))->tp_flags & ((1L <<26))) != 0) || Py_SIZE(item)(((PyVarObject*)(item))->ob_size) != 2) {
1468 | PyErr_SetString(PyExc_ValueError, "items must return 2-tuples");
1469 | goto bail;
1470 | }
1471 | key = PyTuple_GET_ITEM(item, 0)(((PyTupleObject *)(item))->ob_item[0]);
1472 | if (PyUnicode_Check(key)((((((PyObject*)(key))->ob_type))->tp_flags & ((1L<< 28))) != 0)) {
1473 | Py_INCREF(key)( _Py_RefTotal++ , ((PyObject*)(key))->ob_refcnt++);
1474 | kstr = key;
1475 | }
1476 | else if (PyFloat_Check(key)((((PyObject*)(key))->ob_type) == (&PyFloat_Type) || PyType_IsSubtype ((((PyObject*)(key))->ob_type), (&PyFloat_Type)))) {
1477 | kstr = encoder_encode_float(s, key);
1478 | if (kstr == NULL((void*)0))
1479 | goto bail;
1480 | }
1481 | else if (key == Py_True((PyObject *) &_Py_TrueStruct) || key == Py_False((PyObject *) &_Py_FalseStruct) || key == Py_None(&_Py_NoneStruct)) {
1482 | /* This must come before the PyLong_Check because
1483 | True and False are also 1 and 0.*/
1484 | kstr = _encoded_const(key);
1485 | if (kstr == NULL((void*)0))
1486 | goto bail;
1487 | }
1488 | else if (PyLong_Check(key)((((((PyObject*)(key))->ob_type))->tp_flags & ((1L<< 24))) != 0)) {
1489 | kstr = PyObject_Str(key);
1490 | if (kstr == NULL((void*)0))
1491 | goto bail;
1492 | }
1493 | else if (skipkeys) {
1494 | Py_DECREF(item)do { if (_Py_RefTotal-- , --((PyObject*)(item))->ob_refcnt != 0) { if (((PyObject*)item)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1494, (PyObject *)(item)); } else _Py_Dealloc((PyObject *)(item)); } while ( 0);
1495 | continue;
1496 | }
1497 | else {
1498 | /* TODO: include repr of key */
1499 | PyErr_SetString(PyExc_TypeError, "keys must be a string");
1500 | goto bail;
1501 | }
1502 |
1503 | if (idx) {
1504 | if (PyList_Append(rval, s->item_separator))
1505 | goto bail;
1506 | }
1507 |
1508 | encoded = encoder_encode_string(s, kstr);
1509 | Py_CLEAR(kstr)do { if (kstr) { PyObject *_py_tmp = (PyObject *)(kstr); (kstr ) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1509, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1510 | if (encoded == NULL((void*)0))
1511 | goto bail;
1512 | if (PyList_Append(rval, encoded)) {
1513 | Py_DECREF(encoded)do { if (_Py_RefTotal-- , --((PyObject*)(encoded))->ob_refcnt != 0) { if (((PyObject*)encoded)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1513, (PyObject *)(encoded)); } else _Py_Dealloc((PyObject *)(encoded)); } while (0);
1514 | goto bail;
1515 | }
1516 | Py_DECREF(encoded)do { if (_Py_RefTotal-- , --((PyObject*)(encoded))->ob_refcnt != 0) { if (((PyObject*)encoded)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1516, (PyObject *)(encoded)); } else _Py_Dealloc((PyObject *)(encoded)); } while (0);
1517 | if (PyList_Append(rval, s->key_separator))
1518 | goto bail;
1519 |
1520 | value = PyTuple_GET_ITEM(item, 1)(((PyTupleObject *)(item))->ob_item[1]);
1521 | if (encoder_listencode_obj(s, rval, value, indent_level))
1522 | goto bail;
1523 | idx += 1;
1524 | Py_DECREF(item)do { if (_Py_RefTotal-- , --((PyObject*)(item))->ob_refcnt != 0) { if (((PyObject*)item)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1524, (PyObject *)(item)); } else _Py_Dealloc((PyObject *)(item)); } while ( 0);
1525 | }
1526 | if (PyErr_Occurred())
1527 | goto bail;
1528 | Py_CLEAR(it)do { if (it) { PyObject *_py_tmp = (PyObject *)(it); (it) = ( (void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp)) ->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1528, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1529 |
1530 | if (ident != NULL((void*)0)) {
1531 | if (PyDict_DelItem(s->markers, ident))
1532 | goto bail;
1533 | Py_CLEAR(ident)do { if (ident) { PyObject *_py_tmp = (PyObject *)(ident); (ident ) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1533, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1534 | }
1535 | /* TODO DOES NOT RUN; dead code
1536 | if (s->indent != Py_None) {
1537 | indent_level -= 1;
1538 |
1539 | yield '\n' + (' ' * (_indent * _current_indent_level))
1540 | }*/
1541 | if (PyList_Append(rval, close_dict))
1542 | goto bail;
1543 | return 0;
1544 |
1545 | bail:
1546 | Py_XDECREF(it)do { if ((it) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(it))->ob_refcnt != 0) { if (((PyObject*)it )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1546, (PyObject *)(it)); } else _Py_Dealloc((PyObject *)(it )); } while (0); } while (0);
1547 | Py_XDECREF(item)do { if ((item) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(item))->ob_refcnt != 0) { if (((PyObject *)item)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1547, (PyObject *)(item)); } else _Py_Dealloc((PyObject *)( item)); } while (0); } while (0);
1548 | Py_XDECREF(kstr)do { if ((kstr) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(kstr))->ob_refcnt != 0) { if (((PyObject *)kstr)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1548, (PyObject *)(kstr)); } else _Py_Dealloc((PyObject *)( kstr)); } while (0); } while (0);
1549 | Py_XDECREF(ident)do { if ((ident) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject *)ident)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1549, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *) (ident)); } while (0); } while (0);
1550 | return -1;
1551 | }
1552 |
1553 |
1554 | static int
1555 | encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ssize_t indent_level)
1556 | {
1557 | /* Encode Python list seq to a JSON term, rval is a PyList */
1558 | static PyObject *open_array = NULL((void*)0);
1559 | static PyObject *close_array = NULL((void*)0);
1560 | static PyObject *empty_array = NULL((void*)0);
1561 | PyObject *ident = NULL((void*)0);
1562 | PyObject *s_fast = NULL((void*)0);
1563 | Py_ssize_t num_items;
1564 | PyObject **seq_items;
1565 | Py_ssize_t i;
1566 |
1567 | if (open_array == NULL((void*)0) || close_array == NULL((void*)0) || empty_array == NULL((void*)0)) {
1568 | open_array = PyUnicode_InternFromString("[");
1569 | close_array = PyUnicode_InternFromString("]");
1570 | empty_array = PyUnicode_InternFromString("[]");
1571 | if (open_array == NULL((void*)0) || close_array == NULL((void*)0) || empty_array == NULL((void*)0))
1572 | return -1;
1573 | }
1574 | ident = NULL((void*)0);
1575 | s_fast = PySequence_Fast(seq, "_iterencode_list needs a sequence");
1576 | if (s_fast == NULL((void*)0))
1577 | return -1;
1578 | num_items = PySequence_Fast_GET_SIZE(s_fast)(((((((PyObject*)(s_fast))->ob_type))->tp_flags & ( (1L<<25))) != 0) ? (((PyVarObject*)(s_fast))->ob_size ) : (((PyVarObject*)(s_fast))->ob_size));
1579 | if (num_items == 0) {
1580 | Py_DECREF(s_fast)do { if (_Py_RefTotal-- , --((PyObject*)(s_fast))->ob_refcnt != 0) { if (((PyObject*)s_fast)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1580, (PyObject *)(s_fast)); } else _Py_Dealloc((PyObject *)(s_fast)); } while (0);
1581 | return PyList_Append(rval, empty_array);
1582 | }
1583 |
1584 | if (s->markers != Py_None(&_Py_NoneStruct)) {
1585 | int has_key;
1586 | ident = PyLong_FromVoidPtr(seq);
1587 | if (ident == NULL((void*)0))
1588 | goto bail;
1589 | has_key = PyDict_Contains(s->markers, ident);
1590 | if (has_key) {
1591 | if (has_key != -1)
1592 | PyErr_SetString(PyExc_ValueError, "Circular reference detected");
1593 | goto bail;
1594 | }
1595 | if (PyDict_SetItem(s->markers, ident, seq)) {
1596 | goto bail;
1597 | }
1598 | }
1599 |
1600 | seq_items = PySequence_Fast_ITEMS(s_fast)(((((((PyObject*)(s_fast))->ob_type))->tp_flags & ( (1L<<25))) != 0) ? ((PyListObject *)(s_fast))->ob_item : ((PyTupleObject *)(s_fast))->ob_item);
1601 | if (PyList_Append(rval, open_array))
1602 | goto bail;
1603 | if (s->indent != Py_None(&_Py_NoneStruct)) {
1604 | /* TODO: DOES NOT RUN */
1605 | indent_level += 1;
1606 | /*
1607 | newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
1608 | separator = _item_separator + newline_indent
1609 | buf += newline_indent
1610 | */
1611 | }
1612 | for (i = 0; i < num_items; i++) {
1613 | PyObject *obj = seq_items[i];
1614 | if (i) {
1615 | if (PyList_Append(rval, s->item_separator))
1616 | goto bail;
1617 | }
1618 | if (encoder_listencode_obj(s, rval, obj, indent_level))
1619 | goto bail;
1620 | }
1621 | if (ident != NULL((void*)0)) {
1622 | if (PyDict_DelItem(s->markers, ident))
1623 | goto bail;
1624 | Py_CLEAR(ident)do { if (ident) { PyObject *_py_tmp = (PyObject *)(ident); (ident ) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp ))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1624, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1625 | }
1626 |
1627 | /* TODO: DOES NOT RUN
1628 | if (s->indent != Py_None) {
1629 | indent_level -= 1;
1630 |
1631 | yield '\n' + (' ' * (_indent * _current_indent_level))
1632 | }*/
1633 | if (PyList_Append(rval, close_array))
1634 | goto bail;
1635 | Py_DECREF(s_fast)do { if (_Py_RefTotal-- , --((PyObject*)(s_fast))->ob_refcnt != 0) { if (((PyObject*)s_fast)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1635, (PyObject *)(s_fast)); } else _Py_Dealloc((PyObject *)(s_fast)); } while (0);
1636 | return 0;
1637 |
1638 | bail:
1639 | Py_XDECREF(ident)do { if ((ident) == ((void*)0)) ; else do { if (_Py_RefTotal-- , --((PyObject*)(ident))->ob_refcnt != 0) { if (((PyObject *)ident)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1639, (PyObject *)(ident)); } else _Py_Dealloc((PyObject *) (ident)); } while (0); } while (0);
1640 | Py_DECREF(s_fast)do { if (_Py_RefTotal-- , --((PyObject*)(s_fast))->ob_refcnt != 0) { if (((PyObject*)s_fast)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1640, (PyObject *)(s_fast)); } else _Py_Dealloc((PyObject *)(s_fast)); } while (0);
1641 | return -1;
1642 | }
1643 |
1644 | static void
1645 | encoder_dealloc(PyObject *self)
1646 | {
1647 | /* Deallocate Encoder */
1648 | encoder_clear(self);
1649 | Py_TYPE(self)(((PyObject*)(self))->ob_type)->tp_free(self);
1650 | }
1651 |
1652 | static int
1653 | encoder_traverse(PyObject *self, visitproc visit, void *arg)
1654 | {
1655 | PyEncoderObject *s;
1656 | assert(PyEncoder_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyEncoderType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyEncoderType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1656, "PyEncoder_Check(self)") : (void)0);
1657 | s = (PyEncoderObject *)self;
1658 | Py_VISIT(s->markers)do { if (s->markers) { int vret = visit((PyObject *)(s-> markers), arg); if (vret) return vret; } } while (0);
1659 | Py_VISIT(s->defaultfn)do { if (s->defaultfn) { int vret = visit((PyObject *)(s-> defaultfn), arg); if (vret) return vret; } } while (0);
1660 | Py_VISIT(s->encoder)do { if (s->encoder) { int vret = visit((PyObject *)(s-> encoder), arg); if (vret) return vret; } } while (0);
1661 | Py_VISIT(s->indent)do { if (s->indent) { int vret = visit((PyObject *)(s-> indent), arg); if (vret) return vret; } } while (0);
1662 | Py_VISIT(s->key_separator)do { if (s->key_separator) { int vret = visit((PyObject *) (s->key_separator), arg); if (vret) return vret; } } while (0);
1663 | Py_VISIT(s->item_separator)do { if (s->item_separator) { int vret = visit((PyObject * )(s->item_separator), arg); if (vret) return vret; } } while (0);
1664 | Py_VISIT(s->sort_keys)do { if (s->sort_keys) { int vret = visit((PyObject *)(s-> sort_keys), arg); if (vret) return vret; } } while (0);
1665 | Py_VISIT(s->skipkeys)do { if (s->skipkeys) { int vret = visit((PyObject *)(s-> skipkeys), arg); if (vret) return vret; } } while (0);
1666 | return 0;
1667 | }
1668 |
1669 | static int
1670 | encoder_clear(PyObject *self)
1671 | {
1672 | /* Deallocate Encoder */
1673 | PyEncoderObject *s;
1674 | assert(PyEncoder_Check(self))(__builtin_expect(!(((((PyObject*)(self))->ob_type) == (& PyEncoderType) || PyType_IsSubtype((((PyObject*)(self))->ob_type ), (&PyEncoderType)))), 0) ? __assert_rtn(__func__, "/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1674, "PyEncoder_Check(self)") : (void)0);
1675 | s = (PyEncoderObject *)self;
1676 | Py_CLEAR(s->markers)do { if (s->markers) { PyObject *_py_tmp = (PyObject *)(s-> markers); (s->markers) = ((void*)0); do { if (_Py_RefTotal -- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1676, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1677 | Py_CLEAR(s->defaultfn)do { if (s->defaultfn) { PyObject *_py_tmp = (PyObject *)( s->defaultfn); (s->defaultfn) = ((void*)0); do { if (_Py_RefTotal -- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1677, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1678 | Py_CLEAR(s->encoder)do { if (s->encoder) { PyObject *_py_tmp = (PyObject *)(s-> encoder); (s->encoder) = ((void*)0); do { if (_Py_RefTotal -- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1678, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1679 | Py_CLEAR(s->indent)do { if (s->indent) { PyObject *_py_tmp = (PyObject *)(s-> indent); (s->indent) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1679, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1680 | Py_CLEAR(s->key_separator)do { if (s->key_separator) { PyObject *_py_tmp = (PyObject *)(s->key_separator); (s->key_separator) = ((void*)0); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1680, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
1681 | Py_CLEAR(s->item_separator)do { if (s->item_separator) { PyObject *_py_tmp = (PyObject *)(s->item_separator); (s->item_separator) = ((void*)0 ); do { if (_Py_RefTotal-- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject*)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1681, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject *)(_py_tmp)); } while (0); } } while (0);
1682 | Py_CLEAR(s->sort_keys)do { if (s->sort_keys) { PyObject *_py_tmp = (PyObject *)( s->sort_keys); (s->sort_keys) = ((void*)0); do { if (_Py_RefTotal -- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1682, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1683 | Py_CLEAR(s->skipkeys)do { if (s->skipkeys) { PyObject *_py_tmp = (PyObject *)(s ->skipkeys); (s->skipkeys) = ((void*)0); do { if (_Py_RefTotal -- , --((PyObject*)(_py_tmp))->ob_refcnt != 0) { if (((PyObject *)_py_tmp)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1683, (PyObject *)(_py_tmp)); } else _Py_Dealloc((PyObject * )(_py_tmp)); } while (0); } } while (0);
1684 | return 0;
1685 | }
1686 |
1687 | PyDoc_STRVAR(encoder_doc, "_iterencode(obj, _current_indent_level) -> iterable")static char encoder_doc[] = "_iterencode(obj, _current_indent_level) -> iterable";
1688 |
1689 | static
1690 | PyTypeObject PyEncoderType = {
1691 | PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void*)0) }, 0 },
1692 | "_json.Encoder", /* tp_name */
1693 | sizeof(PyEncoderObject), /* tp_basicsize */
1694 | 0, /* tp_itemsize */
1695 | encoder_dealloc, /* tp_dealloc */
1696 | 0, /* tp_print */
1697 | 0, /* tp_getattr */
1698 | 0, /* tp_setattr */
1699 | 0, /* tp_compare */
1700 | 0, /* tp_repr */
1701 | 0, /* tp_as_number */
1702 | 0, /* tp_as_sequence */
1703 | 0, /* tp_as_mapping */
1704 | 0, /* tp_hash */
1705 | encoder_call, /* tp_call */
1706 | 0, /* tp_str */
1707 | 0, /* tp_getattro */
1708 | 0, /* tp_setattro */
1709 | 0, /* tp_as_buffer */
1710 | Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0) | Py_TPFLAGS_HAVE_GC(1L<<14), /* tp_flags */
1711 | encoder_doc, /* tp_doc */
1712 | encoder_traverse, /* tp_traverse */
1713 | encoder_clear, /* tp_clear */
1714 | 0, /* tp_richcompare */
1715 | 0, /* tp_weaklistoffset */
1716 | 0, /* tp_iter */
1717 | 0, /* tp_iternext */
1718 | 0, /* tp_methods */
1719 | encoder_members, /* tp_members */
1720 | 0, /* tp_getset */
1721 | 0, /* tp_base */
1722 | 0, /* tp_dict */
1723 | 0, /* tp_descr_get */
1724 | 0, /* tp_descr_set */
1725 | 0, /* tp_dictoffset */
1726 | encoder_init, /* tp_init */
1727 | 0, /* tp_alloc */
1728 | encoder_new, /* tp_new */
1729 | 0, /* tp_free */
1730 | };
1731 |
1732 | static PyMethodDef speedups_methods[] = {
1733 | {"encode_basestring_ascii",
1734 | (PyCFunction)py_encode_basestring_ascii,
1735 | METH_O0x0008,
1736 | pydoc_encode_basestring_ascii},
1737 | {"scanstring",
1738 | (PyCFunction)py_scanstring,
1739 | METH_VARARGS0x0001,
1740 | pydoc_scanstring},
1741 | {NULL((void*)0), NULL((void*)0), 0, NULL((void*)0)}
1742 | };
1743 |
1744 | PyDoc_STRVAR(module_doc,static char module_doc[] = "json speedups\n"
1745 | "json speedups\n")static char module_doc[] = "json speedups\n";
1746 |
1747 | static struct PyModuleDef jsonmodule = {
1748 | PyModuleDef_HEAD_INIT{ { 0, 0, 1, ((void*)0) }, ((void*)0), 0, ((void*)0), },
1749 | "_json",
1750 | module_doc,
1751 | -1,
1752 | speedups_methods,
1753 | NULL((void*)0),
1754 | NULL((void*)0),
1755 | NULL((void*)0),
1756 | NULL((void*)0)
1757 | };
1758 |
1759 | PyObject*
1760 | PyInit__json(void)
1761 | {
1762 | PyObject *m = PyModule_Create(&jsonmodule)PyModule_Create2TraceRefs(&jsonmodule, 1013);
1763 | if (!m)
1764 | return NULL((void*)0);
1765 | PyScannerType.tp_new = PyType_GenericNew;
1766 | if (PyType_Ready(&PyScannerType) < 0)
1767 | goto fail;
1768 | PyEncoderType.tp_new = PyType_GenericNew;
1769 | if (PyType_Ready(&PyEncoderType) < 0)
1770 | goto fail;
1771 | Py_INCREF((PyObject*)&PyScannerType)( _Py_RefTotal++ , ((PyObject*)((PyObject*)&PyScannerType ))->ob_refcnt++);
1772 | if (PyModule_AddObject(m, "make_scanner", (PyObject*)&PyScannerType) < 0) {
1773 | Py_DECREF((PyObject*)&PyScannerType)do { if (_Py_RefTotal-- , --((PyObject*)((PyObject*)&PyScannerType ))->ob_refcnt != 0) { if (((PyObject*)(PyObject*)&PyScannerType )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1773, (PyObject *)((PyObject*)&PyScannerType)); } else _Py_Dealloc ((PyObject *)((PyObject*)&PyScannerType)); } while (0);
1774 | goto fail;
1775 | }
1776 | Py_INCREF((PyObject*)&PyEncoderType)( _Py_RefTotal++ , ((PyObject*)((PyObject*)&PyEncoderType ))->ob_refcnt++);
1777 | if (PyModule_AddObject(m, "make_encoder", (PyObject*)&PyEncoderType) < 0) {
1778 | Py_DECREF((PyObject*)&PyEncoderType)do { if (_Py_RefTotal-- , --((PyObject*)((PyObject*)&PyEncoderType ))->ob_refcnt != 0) { if (((PyObject*)(PyObject*)&PyEncoderType )->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c" , 1778, (PyObject *)((PyObject*)&PyEncoderType)); } else _Py_Dealloc ((PyObject *)((PyObject*)&PyEncoderType)); } while (0);
1779 | goto fail;
1780 | }
1781 | return m;
1782 | fail:
1783 | Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt != 0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount ("/Users/brett/Dev/python/3.x/py3k/Modules/_json.c", 1783, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while (0);
1784 | return NULL((void*)0);
1785 | }