blob: 437eab0eae3322712e3ee14e8b851a719f264031 [file] [log] [blame]
Brett Cannon4b964f92008-05-05 20:21:38 +00001#include "Python.h"
2
3#define DEFAULT_ENCODING "utf-8"
4#define S_CHAR(c) (c >= ' ' && c <= '~' && c != '\\' && c != '"')
5#define MIN_EXPANSION 6
6
7#ifdef Py_UNICODE_WIDE
8#define MAX_EXPANSION (2 * MIN_EXPANSION)
9#else
10#define MAX_EXPANSION MIN_EXPANSION
11#endif
12
13static Py_ssize_t
14ascii_escape_char(Py_UNICODE c, char *output, Py_ssize_t chars)
15{
16 Py_UNICODE x;
17 output[chars++] = '\\';
18 switch (c) {
19 case '\\': output[chars++] = (char)c; break;
20 case '"': output[chars++] = (char)c; break;
21 case '\b': output[chars++] = 'b'; break;
22 case '\f': output[chars++] = 'f'; break;
23 case '\n': output[chars++] = 'n'; break;
24 case '\r': output[chars++] = 'r'; break;
25 case '\t': output[chars++] = 't'; break;
26 default:
27#ifdef Py_UNICODE_WIDE
28 if (c >= 0x10000) {
29 /* UTF-16 surrogate pair */
30 Py_UNICODE v = c - 0x10000;
31 c = 0xd800 | ((v >> 10) & 0x3ff);
32 output[chars++] = 'u';
33 x = (c & 0xf000) >> 12;
34 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
35 x = (c & 0x0f00) >> 8;
36 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
37 x = (c & 0x00f0) >> 4;
38 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
39 x = (c & 0x000f);
40 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
41 c = 0xdc00 | (v & 0x3ff);
42 output[chars++] = '\\';
43 }
44#endif
45 output[chars++] = 'u';
46 x = (c & 0xf000) >> 12;
47 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
48 x = (c & 0x0f00) >> 8;
49 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
50 x = (c & 0x00f0) >> 4;
51 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
52 x = (c & 0x000f);
53 output[chars++] = (x < 10) ? '0' + x : 'a' + (x - 10);
54 }
55 return chars;
56}
57
58static PyObject *
59ascii_escape_unicode(PyObject *pystr)
60{
61 Py_ssize_t i;
62 Py_ssize_t input_chars;
63 Py_ssize_t output_size;
64 Py_ssize_t chars;
65 PyObject *rval;
66 char *output;
67 Py_UNICODE *input_unicode;
68
69 input_chars = PyUnicode_GET_SIZE(pystr);
70 input_unicode = PyUnicode_AS_UNICODE(pystr);
71 /* One char input can be up to 6 chars output, estimate 4 of these */
72 output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
Gregory P. Smithdd96db62008-06-09 04:58:54 +000073 rval = PyString_FromStringAndSize(NULL, output_size);
Brett Cannon4b964f92008-05-05 20:21:38 +000074 if (rval == NULL) {
75 return NULL;
76 }
Gregory P. Smithdd96db62008-06-09 04:58:54 +000077 output = PyString_AS_STRING(rval);
Brett Cannon4b964f92008-05-05 20:21:38 +000078 chars = 0;
79 output[chars++] = '"';
80 for (i = 0; i < input_chars; i++) {
81 Py_UNICODE c = input_unicode[i];
82 if (S_CHAR(c)) {
83 output[chars++] = (char)c;
84 }
85 else {
86 chars = ascii_escape_char(c, output, chars);
87 }
88 if (output_size - chars < (1 + MAX_EXPANSION)) {
89 /* There's more than four, so let's resize by a lot */
90 output_size *= 2;
91 /* This is an upper bound */
92 if (output_size > 2 + (input_chars * MAX_EXPANSION)) {
93 output_size = 2 + (input_chars * MAX_EXPANSION);
94 }
Gregory P. Smithdd96db62008-06-09 04:58:54 +000095 if (_PyString_Resize(&rval, output_size) == -1) {
Brett Cannon4b964f92008-05-05 20:21:38 +000096 return NULL;
97 }
Gregory P. Smithdd96db62008-06-09 04:58:54 +000098 output = PyString_AS_STRING(rval);
Brett Cannon4b964f92008-05-05 20:21:38 +000099 }
100 }
101 output[chars++] = '"';
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000102 if (_PyString_Resize(&rval, chars) == -1) {
Brett Cannon4b964f92008-05-05 20:21:38 +0000103 return NULL;
104 }
105 return rval;
106}
107
108static PyObject *
109ascii_escape_str(PyObject *pystr)
110{
111 Py_ssize_t i;
112 Py_ssize_t input_chars;
113 Py_ssize_t output_size;
114 Py_ssize_t chars;
115 PyObject *rval;
116 char *output;
117 char *input_str;
118
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000119 input_chars = PyString_GET_SIZE(pystr);
120 input_str = PyString_AS_STRING(pystr);
Brett Cannon4b964f92008-05-05 20:21:38 +0000121 /* One char input can be up to 6 chars output, estimate 4 of these */
122 output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000123 rval = PyString_FromStringAndSize(NULL, output_size);
Brett Cannon4b964f92008-05-05 20:21:38 +0000124 if (rval == NULL) {
125 return NULL;
126 }
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000127 output = PyString_AS_STRING(rval);
Brett Cannon4b964f92008-05-05 20:21:38 +0000128 chars = 0;
129 output[chars++] = '"';
130 for (i = 0; i < input_chars; i++) {
131 Py_UNICODE c = (Py_UNICODE)input_str[i];
132 if (S_CHAR(c)) {
133 output[chars++] = (char)c;
134 }
135 else if (c > 0x7F) {
136 /* We hit a non-ASCII character, bail to unicode mode */
137 PyObject *uni;
138 Py_DECREF(rval);
139 uni = PyUnicode_DecodeUTF8(input_str, input_chars, "strict");
140 if (uni == NULL) {
141 return NULL;
142 }
143 rval = ascii_escape_unicode(uni);
144 Py_DECREF(uni);
145 return rval;
146 }
147 else {
148 chars = ascii_escape_char(c, output, chars);
149 }
150 /* An ASCII char can't possibly expand to a surrogate! */
151 if (output_size - chars < (1 + MIN_EXPANSION)) {
152 /* There's more than four, so let's resize by a lot */
153 output_size *= 2;
154 if (output_size > 2 + (input_chars * MIN_EXPANSION)) {
155 output_size = 2 + (input_chars * MIN_EXPANSION);
156 }
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000157 if (_PyString_Resize(&rval, output_size) == -1) {
Brett Cannon4b964f92008-05-05 20:21:38 +0000158 return NULL;
159 }
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000160 output = PyString_AS_STRING(rval);
Brett Cannon4b964f92008-05-05 20:21:38 +0000161 }
162 }
163 output[chars++] = '"';
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000164 if (_PyString_Resize(&rval, chars) == -1) {
Brett Cannon4b964f92008-05-05 20:21:38 +0000165 return NULL;
166 }
167 return rval;
168}
169
170void
171raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
172{
173 static PyObject *errmsg_fn = NULL;
174 PyObject *pymsg;
175 if (errmsg_fn == NULL) {
176 PyObject *decoder = PyImport_ImportModule("json.decoder");
177 if (decoder == NULL)
178 return;
179 errmsg_fn = PyObject_GetAttrString(decoder, "errmsg");
180 if (errmsg_fn == NULL)
181 return;
Benjamin Peterson595e3cb2008-10-16 21:09:28 +0000182 Py_DECREF(decoder);
Brett Cannon4b964f92008-05-05 20:21:38 +0000183 }
184 pymsg = PyObject_CallFunction(errmsg_fn, "(zOn)", msg, s, end);
Benjamin Peterson595e3cb2008-10-16 21:09:28 +0000185 if (pymsg) {
186 PyErr_SetObject(PyExc_ValueError, pymsg);
187 Py_DECREF(pymsg);
188 }
Brett Cannon4b964f92008-05-05 20:21:38 +0000189/*
190
191def linecol(doc, pos):
192 lineno = doc.count('\n', 0, pos) + 1
193 if lineno == 1:
194 colno = pos
195 else:
196 colno = pos - doc.rindex('\n', 0, pos)
197 return lineno, colno
198
199def errmsg(msg, doc, pos, end=None):
200 lineno, colno = linecol(doc, pos)
201 if end is None:
202 return '%s: line %d column %d (char %d)' % (msg, lineno, colno, pos)
203 endlineno, endcolno = linecol(doc, end)
204 return '%s: line %d column %d - line %d column %d (char %d - %d)' % (
205 msg, lineno, colno, endlineno, endcolno, pos, end)
206
207*/
208}
209
210static PyObject *
211join_list_unicode(PyObject *lst)
212{
213 static PyObject *ustr = NULL;
214 static PyObject *joinstr = NULL;
215 if (ustr == NULL) {
216 Py_UNICODE c = 0;
217 ustr = PyUnicode_FromUnicode(&c, 0);
218 }
219 if (joinstr == NULL) {
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000220 joinstr = PyString_InternFromString("join");
Brett Cannon4b964f92008-05-05 20:21:38 +0000221 }
222 if (joinstr == NULL || ustr == NULL) {
223 return NULL;
224 }
225 return PyObject_CallMethodObjArgs(ustr, joinstr, lst, NULL);
226}
227
228static PyObject *
229scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
230{
231 PyObject *rval;
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000232 Py_ssize_t len = PyString_GET_SIZE(pystr);
Brett Cannon4b964f92008-05-05 20:21:38 +0000233 Py_ssize_t begin = end - 1;
234 Py_ssize_t next = begin;
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000235 char *buf = PyString_AS_STRING(pystr);
Brett Cannon4b964f92008-05-05 20:21:38 +0000236 PyObject *chunks = PyList_New(0);
237 if (chunks == NULL) {
238 goto bail;
239 }
Bob Ippolitod648f642008-07-19 21:59:50 +0000240 if (end < 0 || len <= end) {
241 PyErr_SetString(PyExc_ValueError, "end is out of bounds");
242 goto bail;
243 }
Brett Cannon4b964f92008-05-05 20:21:38 +0000244 while (1) {
245 /* Find the end of the string or the next escape */
246 Py_UNICODE c = 0;
247 PyObject *chunk = NULL;
248 for (next = end; next < len; next++) {
249 c = buf[next];
250 if (c == '"' || c == '\\') {
251 break;
252 }
253 else if (strict && c <= 0x1f) {
Bob Ippolitod648f642008-07-19 21:59:50 +0000254 raise_errmsg("Invalid control character at", pystr, next);
Brett Cannon4b964f92008-05-05 20:21:38 +0000255 goto bail;
256 }
257 }
258 if (!(c == '"' || c == '\\')) {
259 raise_errmsg("Unterminated string starting at", pystr, begin);
260 goto bail;
261 }
262 /* Pick up this chunk if it's not zero length */
263 if (next != end) {
264 PyObject *strchunk = PyBuffer_FromMemory(&buf[end], next - end);
265 if (strchunk == NULL) {
266 goto bail;
267 }
268 chunk = PyUnicode_FromEncodedObject(strchunk, encoding, NULL);
269 Py_DECREF(strchunk);
270 if (chunk == NULL) {
271 goto bail;
272 }
273 if (PyList_Append(chunks, chunk)) {
274 goto bail;
275 }
276 Py_DECREF(chunk);
277 }
278 next++;
279 if (c == '"') {
280 end = next;
281 break;
282 }
283 if (next == len) {
284 raise_errmsg("Unterminated string starting at", pystr, begin);
285 goto bail;
286 }
287 c = buf[next];
288 if (c != 'u') {
289 /* Non-unicode backslash escapes */
290 end = next + 1;
291 switch (c) {
292 case '"': break;
293 case '\\': break;
294 case '/': break;
295 case 'b': c = '\b'; break;
296 case 'f': c = '\f'; break;
297 case 'n': c = '\n'; break;
298 case 'r': c = '\r'; break;
299 case 't': c = '\t'; break;
300 default: c = 0;
301 }
302 if (c == 0) {
303 raise_errmsg("Invalid \\escape", pystr, end - 2);
304 goto bail;
305 }
306 }
307 else {
308 c = 0;
309 next++;
310 end = next + 4;
311 if (end >= len) {
312 raise_errmsg("Invalid \\uXXXX escape", pystr, next - 1);
313 goto bail;
314 }
315 /* Decode 4 hex digits */
316 for (; next < end; next++) {
317 Py_ssize_t shl = (end - next - 1) << 2;
318 Py_UNICODE digit = buf[next];
319 switch (digit) {
320 case '0': case '1': case '2': case '3': case '4':
321 case '5': case '6': case '7': case '8': case '9':
322 c |= (digit - '0') << shl; break;
323 case 'a': case 'b': case 'c': case 'd': case 'e':
324 case 'f':
325 c |= (digit - 'a' + 10) << shl; break;
326 case 'A': case 'B': case 'C': case 'D': case 'E':
327 case 'F':
328 c |= (digit - 'A' + 10) << shl; break;
329 default:
330 raise_errmsg("Invalid \\uXXXX escape", pystr, end - 5);
331 goto bail;
332 }
333 }
334#ifdef Py_UNICODE_WIDE
335 /* Surrogate pair */
336 if (c >= 0xd800 && c <= 0xdbff) {
337 Py_UNICODE c2 = 0;
338 if (end + 6 >= len) {
339 raise_errmsg("Invalid \\uXXXX\\uXXXX surrogate pair", pystr,
340 end - 5);
341 }
342 if (buf[next++] != '\\' || buf[next++] != 'u') {
343 raise_errmsg("Invalid \\uXXXX\\uXXXX surrogate pair", pystr,
344 end - 5);
345 }
346 end += 6;
347 /* Decode 4 hex digits */
348 for (; next < end; next++) {
349 Py_ssize_t shl = (end - next - 1) << 2;
350 Py_UNICODE digit = buf[next];
351 switch (digit) {
352 case '0': case '1': case '2': case '3': case '4':
353 case '5': case '6': case '7': case '8': case '9':
354 c2 |= (digit - '0') << shl; break;
355 case 'a': case 'b': case 'c': case 'd': case 'e':
356 case 'f':
357 c2 |= (digit - 'a' + 10) << shl; break;
358 case 'A': case 'B': case 'C': case 'D': case 'E':
359 case 'F':
360 c2 |= (digit - 'A' + 10) << shl; break;
361 default:
362 raise_errmsg("Invalid \\uXXXX escape", pystr, end - 5);
363 goto bail;
364 }
365 }
366 c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00));
367 }
368#endif
369 }
370 chunk = PyUnicode_FromUnicode(&c, 1);
371 if (chunk == NULL) {
372 goto bail;
373 }
374 if (PyList_Append(chunks, chunk)) {
375 goto bail;
376 }
377 Py_DECREF(chunk);
378 }
379
380 rval = join_list_unicode(chunks);
381 if (rval == NULL) {
382 goto bail;
383 }
384 Py_DECREF(chunks);
385 chunks = NULL;
386 return Py_BuildValue("(Nn)", rval, end);
387bail:
388 Py_XDECREF(chunks);
389 return NULL;
390}
391
392
393static PyObject *
394scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict)
395{
396 PyObject *rval;
397 Py_ssize_t len = PyUnicode_GET_SIZE(pystr);
398 Py_ssize_t begin = end - 1;
399 Py_ssize_t next = begin;
400 const Py_UNICODE *buf = PyUnicode_AS_UNICODE(pystr);
401 PyObject *chunks = PyList_New(0);
402 if (chunks == NULL) {
403 goto bail;
404 }
Bob Ippolitod648f642008-07-19 21:59:50 +0000405 if (end < 0 || len <= end) {
406 PyErr_SetString(PyExc_ValueError, "end is out of bounds");
407 goto bail;
408 }
Brett Cannon4b964f92008-05-05 20:21:38 +0000409 while (1) {
410 /* Find the end of the string or the next escape */
411 Py_UNICODE c = 0;
412 PyObject *chunk = NULL;
413 for (next = end; next < len; next++) {
414 c = buf[next];
415 if (c == '"' || c == '\\') {
416 break;
417 }
418 else if (strict && c <= 0x1f) {
Bob Ippolitod648f642008-07-19 21:59:50 +0000419 raise_errmsg("Invalid control character at", pystr, next);
Brett Cannon4b964f92008-05-05 20:21:38 +0000420 goto bail;
421 }
422 }
423 if (!(c == '"' || c == '\\')) {
424 raise_errmsg("Unterminated string starting at", pystr, begin);
425 goto bail;
426 }
427 /* Pick up this chunk if it's not zero length */
428 if (next != end) {
429 chunk = PyUnicode_FromUnicode(&buf[end], next - end);
430 if (chunk == NULL) {
431 goto bail;
432 }
433 if (PyList_Append(chunks, chunk)) {
Benjamin Peterson87e6ad22008-10-16 21:27:54 +0000434 Py_DECREF(chunk);
Brett Cannon4b964f92008-05-05 20:21:38 +0000435 goto bail;
436 }
437 Py_DECREF(chunk);
438 }
439 next++;
440 if (c == '"') {
441 end = next;
442 break;
443 }
444 if (next == len) {
445 raise_errmsg("Unterminated string starting at", pystr, begin);
446 goto bail;
447 }
448 c = buf[next];
449 if (c != 'u') {
450 /* Non-unicode backslash escapes */
451 end = next + 1;
452 switch (c) {
453 case '"': break;
454 case '\\': break;
455 case '/': break;
456 case 'b': c = '\b'; break;
457 case 'f': c = '\f'; break;
458 case 'n': c = '\n'; break;
459 case 'r': c = '\r'; break;
460 case 't': c = '\t'; break;
461 default: c = 0;
462 }
463 if (c == 0) {
464 raise_errmsg("Invalid \\escape", pystr, end - 2);
465 goto bail;
466 }
467 }
468 else {
469 c = 0;
470 next++;
471 end = next + 4;
472 if (end >= len) {
473 raise_errmsg("Invalid \\uXXXX escape", pystr, next - 1);
474 goto bail;
475 }
476 /* Decode 4 hex digits */
477 for (; next < end; next++) {
478 Py_ssize_t shl = (end - next - 1) << 2;
479 Py_UNICODE digit = buf[next];
480 switch (digit) {
481 case '0': case '1': case '2': case '3': case '4':
482 case '5': case '6': case '7': case '8': case '9':
483 c |= (digit - '0') << shl; break;
484 case 'a': case 'b': case 'c': case 'd': case 'e':
485 case 'f':
486 c |= (digit - 'a' + 10) << shl; break;
487 case 'A': case 'B': case 'C': case 'D': case 'E':
488 case 'F':
489 c |= (digit - 'A' + 10) << shl; break;
490 default:
491 raise_errmsg("Invalid \\uXXXX escape", pystr, end - 5);
492 goto bail;
493 }
494 }
495#ifdef Py_UNICODE_WIDE
496 /* Surrogate pair */
497 if (c >= 0xd800 && c <= 0xdbff) {
498 Py_UNICODE c2 = 0;
499 if (end + 6 >= len) {
500 raise_errmsg("Invalid \\uXXXX\\uXXXX surrogate pair", pystr,
501 end - 5);
502 }
503 if (buf[next++] != '\\' || buf[next++] != 'u') {
504 raise_errmsg("Invalid \\uXXXX\\uXXXX surrogate pair", pystr,
505 end - 5);
506 }
507 end += 6;
508 /* Decode 4 hex digits */
509 for (; next < end; next++) {
510 Py_ssize_t shl = (end - next - 1) << 2;
511 Py_UNICODE digit = buf[next];
512 switch (digit) {
513 case '0': case '1': case '2': case '3': case '4':
514 case '5': case '6': case '7': case '8': case '9':
515 c2 |= (digit - '0') << shl; break;
516 case 'a': case 'b': case 'c': case 'd': case 'e':
517 case 'f':
518 c2 |= (digit - 'a' + 10) << shl; break;
519 case 'A': case 'B': case 'C': case 'D': case 'E':
520 case 'F':
521 c2 |= (digit - 'A' + 10) << shl; break;
522 default:
523 raise_errmsg("Invalid \\uXXXX escape", pystr, end - 5);
524 goto bail;
525 }
526 }
527 c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00));
528 }
529#endif
530 }
531 chunk = PyUnicode_FromUnicode(&c, 1);
532 if (chunk == NULL) {
533 goto bail;
534 }
535 if (PyList_Append(chunks, chunk)) {
536 goto bail;
537 }
538 Py_DECREF(chunk);
539 }
540
541 rval = join_list_unicode(chunks);
542 if (rval == NULL) {
543 goto bail;
544 }
Benjamin Peterson87e6ad22008-10-16 21:27:54 +0000545 Py_CLEAR(chunks);
Brett Cannon4b964f92008-05-05 20:21:38 +0000546 return Py_BuildValue("(Nn)", rval, end);
547bail:
548 Py_XDECREF(chunks);
549 return NULL;
550}
551
552PyDoc_STRVAR(pydoc_scanstring,
553"scanstring(basestring, end, encoding) -> (str, end)\n");
554
555static PyObject *
556py_scanstring(PyObject* self, PyObject *args)
557{
558 PyObject *pystr;
559 Py_ssize_t end;
560 char *encoding = NULL;
561 int strict = 0;
562 if (!PyArg_ParseTuple(args, "On|zi:scanstring", &pystr, &end, &encoding, &strict)) {
563 return NULL;
564 }
565 if (encoding == NULL) {
566 encoding = DEFAULT_ENCODING;
567 }
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000568 if (PyString_Check(pystr)) {
Brett Cannon4b964f92008-05-05 20:21:38 +0000569 return scanstring_str(pystr, end, encoding, strict);
570 }
571 else if (PyUnicode_Check(pystr)) {
572 return scanstring_unicode(pystr, end, strict);
573 }
574 else {
575 PyErr_Format(PyExc_TypeError,
576 "first argument must be a string or unicode, not %.80s",
577 Py_TYPE(pystr)->tp_name);
578 return NULL;
579 }
580}
581
582PyDoc_STRVAR(pydoc_encode_basestring_ascii,
583"encode_basestring_ascii(basestring) -> str\n");
584
585static PyObject *
586py_encode_basestring_ascii(PyObject* self, PyObject *pystr)
587{
588 /* METH_O */
Gregory P. Smithdd96db62008-06-09 04:58:54 +0000589 if (PyString_Check(pystr)) {
Brett Cannon4b964f92008-05-05 20:21:38 +0000590 return ascii_escape_str(pystr);
591 }
592 else if (PyUnicode_Check(pystr)) {
593 return ascii_escape_unicode(pystr);
594 }
595 else {
596 PyErr_Format(PyExc_TypeError,
597 "first argument must be a string or unicode, not %.80s",
598 Py_TYPE(pystr)->tp_name);
599 return NULL;
600 }
601}
602
603static PyMethodDef json_methods[] = {
604 {"encode_basestring_ascii", (PyCFunction)py_encode_basestring_ascii,
605 METH_O, pydoc_encode_basestring_ascii},
606 {"scanstring", (PyCFunction)py_scanstring, METH_VARARGS,
607 pydoc_scanstring},
608 {NULL, NULL, 0, NULL}
609};
610
611PyDoc_STRVAR(module_doc,
612"json speedups\n");
613
614void
615init_json(void)
616{
617 PyObject *m;
618 m = Py_InitModule3("_json", json_methods, module_doc);
619}