blob: 29f46bbb048b152fe74ee051e76dbc3d85764b02 [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03005PyDoc_STRVAR(_codecs_register__doc__,
6"register($module, search_function, /)\n"
7"--\n"
8"\n"
9"Register a codec search function.\n"
10"\n"
11"Search functions are expected to take one argument, the encoding name in\n"
12"all lower case letters, and either return None, or a tuple of functions\n"
13"(encoder, decoder, stream_reader, stream_writer) (or a CodecInfo object).");
14
15#define _CODECS_REGISTER_METHODDEF \
16 {"register", (PyCFunction)_codecs_register, METH_O, _codecs_register__doc__},
17
18PyDoc_STRVAR(_codecs_lookup__doc__,
19"lookup($module, encoding, /)\n"
20"--\n"
21"\n"
22"Looks up a codec tuple in the Python codec registry and returns a CodecInfo object.");
23
24#define _CODECS_LOOKUP_METHODDEF \
25 {"lookup", (PyCFunction)_codecs_lookup, METH_O, _codecs_lookup__doc__},
26
27static PyObject *
28_codecs_lookup_impl(PyModuleDef *module, const char *encoding);
29
30static PyObject *
31_codecs_lookup(PyModuleDef *module, PyObject *arg)
32{
33 PyObject *return_value = NULL;
34 const char *encoding;
35
36 if (!PyArg_Parse(arg, "s:lookup", &encoding))
37 goto exit;
38 return_value = _codecs_lookup_impl(module, encoding);
39
40exit:
41 return return_value;
42}
43
44PyDoc_STRVAR(_codecs_encode__doc__,
Serhiy Storchakac97a9622015-08-09 12:23:08 +030045"encode($module, /, obj, encoding=\'utf-8\', errors=\'strict\')\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030046"--\n"
47"\n"
48"Encodes obj using the codec registered for encoding.\n"
49"\n"
Serhiy Storchakac97a9622015-08-09 12:23:08 +030050"The default encoding is \'utf-8\'. errors may be given to set a\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030051"different error handling scheme. Default is \'strict\' meaning that encoding\n"
52"errors raise a ValueError. Other possible values are \'ignore\', \'replace\'\n"
53"and \'backslashreplace\' as well as any other name registered with\n"
54"codecs.register_error that can handle ValueErrors.");
55
56#define _CODECS_ENCODE_METHODDEF \
57 {"encode", (PyCFunction)_codecs_encode, METH_VARARGS|METH_KEYWORDS, _codecs_encode__doc__},
58
59static PyObject *
60_codecs_encode_impl(PyModuleDef *module, PyObject *obj, const char *encoding,
61 const char *errors);
62
63static PyObject *
64_codecs_encode(PyModuleDef *module, PyObject *args, PyObject *kwargs)
65{
66 PyObject *return_value = NULL;
67 static char *_keywords[] = {"obj", "encoding", "errors", NULL};
68 PyObject *obj;
69 const char *encoding = NULL;
70 const char *errors = NULL;
71
72 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:encode", _keywords,
73 &obj, &encoding, &errors))
74 goto exit;
75 return_value = _codecs_encode_impl(module, obj, encoding, errors);
76
77exit:
78 return return_value;
79}
80
81PyDoc_STRVAR(_codecs_decode__doc__,
Serhiy Storchakac97a9622015-08-09 12:23:08 +030082"decode($module, /, obj, encoding=\'utf-8\', errors=\'strict\')\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030083"--\n"
84"\n"
85"Decodes obj using the codec registered for encoding.\n"
86"\n"
Serhiy Storchakac97a9622015-08-09 12:23:08 +030087"Default encoding is \'utf-8\'. errors may be given to set a\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030088"different error handling scheme. Default is \'strict\' meaning that encoding\n"
89"errors raise a ValueError. Other possible values are \'ignore\', \'replace\'\n"
90"and \'backslashreplace\' as well as any other name registered with\n"
91"codecs.register_error that can handle ValueErrors.");
92
93#define _CODECS_DECODE_METHODDEF \
94 {"decode", (PyCFunction)_codecs_decode, METH_VARARGS|METH_KEYWORDS, _codecs_decode__doc__},
95
96static PyObject *
97_codecs_decode_impl(PyModuleDef *module, PyObject *obj, const char *encoding,
98 const char *errors);
99
100static PyObject *
101_codecs_decode(PyModuleDef *module, PyObject *args, PyObject *kwargs)
102{
103 PyObject *return_value = NULL;
104 static char *_keywords[] = {"obj", "encoding", "errors", NULL};
105 PyObject *obj;
106 const char *encoding = NULL;
107 const char *errors = NULL;
108
109 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:decode", _keywords,
110 &obj, &encoding, &errors))
111 goto exit;
112 return_value = _codecs_decode_impl(module, obj, encoding, errors);
113
114exit:
115 return return_value;
116}
117
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300118PyDoc_STRVAR(_codecs__forget_codec__doc__,
119"_forget_codec($module, encoding, /)\n"
120"--\n"
121"\n"
122"Purge the named codec from the internal codec lookup cache");
123
124#define _CODECS__FORGET_CODEC_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300125 {"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_O, _codecs__forget_codec__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300126
127static PyObject *
128_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding);
129
130static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300131_codecs__forget_codec(PyModuleDef *module, PyObject *arg)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300132{
133 PyObject *return_value = NULL;
134 const char *encoding;
135
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300136 if (!PyArg_Parse(arg, "s:_forget_codec", &encoding))
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300137 goto exit;
138 return_value = _codecs__forget_codec_impl(module, encoding);
139
140exit:
141 return return_value;
142}
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300143
144PyDoc_STRVAR(_codecs_escape_decode__doc__,
145"escape_decode($module, data, errors=None, /)\n"
146"--\n"
147"\n");
148
149#define _CODECS_ESCAPE_DECODE_METHODDEF \
150 {"escape_decode", (PyCFunction)_codecs_escape_decode, METH_VARARGS, _codecs_escape_decode__doc__},
151
152static PyObject *
153_codecs_escape_decode_impl(PyModuleDef *module, Py_buffer *data,
154 const char *errors);
155
156static PyObject *
157_codecs_escape_decode(PyModuleDef *module, PyObject *args)
158{
159 PyObject *return_value = NULL;
160 Py_buffer data = {NULL, NULL};
161 const char *errors = NULL;
162
163 if (!PyArg_ParseTuple(args, "s*|z:escape_decode",
164 &data, &errors))
165 goto exit;
166 return_value = _codecs_escape_decode_impl(module, &data, errors);
167
168exit:
169 /* Cleanup for data */
170 if (data.obj)
171 PyBuffer_Release(&data);
172
173 return return_value;
174}
175
176PyDoc_STRVAR(_codecs_escape_encode__doc__,
177"escape_encode($module, data, errors=None, /)\n"
178"--\n"
179"\n");
180
181#define _CODECS_ESCAPE_ENCODE_METHODDEF \
182 {"escape_encode", (PyCFunction)_codecs_escape_encode, METH_VARARGS, _codecs_escape_encode__doc__},
183
184static PyObject *
185_codecs_escape_encode_impl(PyModuleDef *module, PyObject *data,
186 const char *errors);
187
188static PyObject *
189_codecs_escape_encode(PyModuleDef *module, PyObject *args)
190{
191 PyObject *return_value = NULL;
192 PyObject *data;
193 const char *errors = NULL;
194
195 if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
196 &PyBytes_Type, &data, &errors))
197 goto exit;
198 return_value = _codecs_escape_encode_impl(module, data, errors);
199
200exit:
201 return return_value;
202}
203
204PyDoc_STRVAR(_codecs_unicode_internal_decode__doc__,
205"unicode_internal_decode($module, obj, errors=None, /)\n"
206"--\n"
207"\n");
208
209#define _CODECS_UNICODE_INTERNAL_DECODE_METHODDEF \
210 {"unicode_internal_decode", (PyCFunction)_codecs_unicode_internal_decode, METH_VARARGS, _codecs_unicode_internal_decode__doc__},
211
212static PyObject *
213_codecs_unicode_internal_decode_impl(PyModuleDef *module, PyObject *obj,
214 const char *errors);
215
216static PyObject *
217_codecs_unicode_internal_decode(PyModuleDef *module, PyObject *args)
218{
219 PyObject *return_value = NULL;
220 PyObject *obj;
221 const char *errors = NULL;
222
223 if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
224 &obj, &errors))
225 goto exit;
226 return_value = _codecs_unicode_internal_decode_impl(module, obj, errors);
227
228exit:
229 return return_value;
230}
231
232PyDoc_STRVAR(_codecs_utf_7_decode__doc__,
233"utf_7_decode($module, data, errors=None, final=False, /)\n"
234"--\n"
235"\n");
236
237#define _CODECS_UTF_7_DECODE_METHODDEF \
238 {"utf_7_decode", (PyCFunction)_codecs_utf_7_decode, METH_VARARGS, _codecs_utf_7_decode__doc__},
239
240static PyObject *
241_codecs_utf_7_decode_impl(PyModuleDef *module, Py_buffer *data,
242 const char *errors, int final);
243
244static PyObject *
245_codecs_utf_7_decode(PyModuleDef *module, PyObject *args)
246{
247 PyObject *return_value = NULL;
248 Py_buffer data = {NULL, NULL};
249 const char *errors = NULL;
250 int final = 0;
251
252 if (!PyArg_ParseTuple(args, "y*|zi:utf_7_decode",
253 &data, &errors, &final))
254 goto exit;
255 return_value = _codecs_utf_7_decode_impl(module, &data, errors, final);
256
257exit:
258 /* Cleanup for data */
259 if (data.obj)
260 PyBuffer_Release(&data);
261
262 return return_value;
263}
264
265PyDoc_STRVAR(_codecs_utf_8_decode__doc__,
266"utf_8_decode($module, data, errors=None, final=False, /)\n"
267"--\n"
268"\n");
269
270#define _CODECS_UTF_8_DECODE_METHODDEF \
271 {"utf_8_decode", (PyCFunction)_codecs_utf_8_decode, METH_VARARGS, _codecs_utf_8_decode__doc__},
272
273static PyObject *
274_codecs_utf_8_decode_impl(PyModuleDef *module, Py_buffer *data,
275 const char *errors, int final);
276
277static PyObject *
278_codecs_utf_8_decode(PyModuleDef *module, PyObject *args)
279{
280 PyObject *return_value = NULL;
281 Py_buffer data = {NULL, NULL};
282 const char *errors = NULL;
283 int final = 0;
284
285 if (!PyArg_ParseTuple(args, "y*|zi:utf_8_decode",
286 &data, &errors, &final))
287 goto exit;
288 return_value = _codecs_utf_8_decode_impl(module, &data, errors, final);
289
290exit:
291 /* Cleanup for data */
292 if (data.obj)
293 PyBuffer_Release(&data);
294
295 return return_value;
296}
297
298PyDoc_STRVAR(_codecs_utf_16_decode__doc__,
299"utf_16_decode($module, data, errors=None, final=False, /)\n"
300"--\n"
301"\n");
302
303#define _CODECS_UTF_16_DECODE_METHODDEF \
304 {"utf_16_decode", (PyCFunction)_codecs_utf_16_decode, METH_VARARGS, _codecs_utf_16_decode__doc__},
305
306static PyObject *
307_codecs_utf_16_decode_impl(PyModuleDef *module, Py_buffer *data,
308 const char *errors, int final);
309
310static PyObject *
311_codecs_utf_16_decode(PyModuleDef *module, PyObject *args)
312{
313 PyObject *return_value = NULL;
314 Py_buffer data = {NULL, NULL};
315 const char *errors = NULL;
316 int final = 0;
317
318 if (!PyArg_ParseTuple(args, "y*|zi:utf_16_decode",
319 &data, &errors, &final))
320 goto exit;
321 return_value = _codecs_utf_16_decode_impl(module, &data, errors, final);
322
323exit:
324 /* Cleanup for data */
325 if (data.obj)
326 PyBuffer_Release(&data);
327
328 return return_value;
329}
330
331PyDoc_STRVAR(_codecs_utf_16_le_decode__doc__,
332"utf_16_le_decode($module, data, errors=None, final=False, /)\n"
333"--\n"
334"\n");
335
336#define _CODECS_UTF_16_LE_DECODE_METHODDEF \
337 {"utf_16_le_decode", (PyCFunction)_codecs_utf_16_le_decode, METH_VARARGS, _codecs_utf_16_le_decode__doc__},
338
339static PyObject *
340_codecs_utf_16_le_decode_impl(PyModuleDef *module, Py_buffer *data,
341 const char *errors, int final);
342
343static PyObject *
344_codecs_utf_16_le_decode(PyModuleDef *module, PyObject *args)
345{
346 PyObject *return_value = NULL;
347 Py_buffer data = {NULL, NULL};
348 const char *errors = NULL;
349 int final = 0;
350
351 if (!PyArg_ParseTuple(args, "y*|zi:utf_16_le_decode",
352 &data, &errors, &final))
353 goto exit;
354 return_value = _codecs_utf_16_le_decode_impl(module, &data, errors, final);
355
356exit:
357 /* Cleanup for data */
358 if (data.obj)
359 PyBuffer_Release(&data);
360
361 return return_value;
362}
363
364PyDoc_STRVAR(_codecs_utf_16_be_decode__doc__,
365"utf_16_be_decode($module, data, errors=None, final=False, /)\n"
366"--\n"
367"\n");
368
369#define _CODECS_UTF_16_BE_DECODE_METHODDEF \
370 {"utf_16_be_decode", (PyCFunction)_codecs_utf_16_be_decode, METH_VARARGS, _codecs_utf_16_be_decode__doc__},
371
372static PyObject *
373_codecs_utf_16_be_decode_impl(PyModuleDef *module, Py_buffer *data,
374 const char *errors, int final);
375
376static PyObject *
377_codecs_utf_16_be_decode(PyModuleDef *module, PyObject *args)
378{
379 PyObject *return_value = NULL;
380 Py_buffer data = {NULL, NULL};
381 const char *errors = NULL;
382 int final = 0;
383
384 if (!PyArg_ParseTuple(args, "y*|zi:utf_16_be_decode",
385 &data, &errors, &final))
386 goto exit;
387 return_value = _codecs_utf_16_be_decode_impl(module, &data, errors, final);
388
389exit:
390 /* Cleanup for data */
391 if (data.obj)
392 PyBuffer_Release(&data);
393
394 return return_value;
395}
396
397PyDoc_STRVAR(_codecs_utf_16_ex_decode__doc__,
398"utf_16_ex_decode($module, data, errors=None, byteorder=0, final=False,\n"
399" /)\n"
400"--\n"
401"\n");
402
403#define _CODECS_UTF_16_EX_DECODE_METHODDEF \
404 {"utf_16_ex_decode", (PyCFunction)_codecs_utf_16_ex_decode, METH_VARARGS, _codecs_utf_16_ex_decode__doc__},
405
406static PyObject *
407_codecs_utf_16_ex_decode_impl(PyModuleDef *module, Py_buffer *data,
408 const char *errors, int byteorder, int final);
409
410static PyObject *
411_codecs_utf_16_ex_decode(PyModuleDef *module, PyObject *args)
412{
413 PyObject *return_value = NULL;
414 Py_buffer data = {NULL, NULL};
415 const char *errors = NULL;
416 int byteorder = 0;
417 int final = 0;
418
419 if (!PyArg_ParseTuple(args, "y*|zii:utf_16_ex_decode",
420 &data, &errors, &byteorder, &final))
421 goto exit;
422 return_value = _codecs_utf_16_ex_decode_impl(module, &data, errors, byteorder, final);
423
424exit:
425 /* Cleanup for data */
426 if (data.obj)
427 PyBuffer_Release(&data);
428
429 return return_value;
430}
431
432PyDoc_STRVAR(_codecs_utf_32_decode__doc__,
433"utf_32_decode($module, data, errors=None, final=False, /)\n"
434"--\n"
435"\n");
436
437#define _CODECS_UTF_32_DECODE_METHODDEF \
438 {"utf_32_decode", (PyCFunction)_codecs_utf_32_decode, METH_VARARGS, _codecs_utf_32_decode__doc__},
439
440static PyObject *
441_codecs_utf_32_decode_impl(PyModuleDef *module, Py_buffer *data,
442 const char *errors, int final);
443
444static PyObject *
445_codecs_utf_32_decode(PyModuleDef *module, PyObject *args)
446{
447 PyObject *return_value = NULL;
448 Py_buffer data = {NULL, NULL};
449 const char *errors = NULL;
450 int final = 0;
451
452 if (!PyArg_ParseTuple(args, "y*|zi:utf_32_decode",
453 &data, &errors, &final))
454 goto exit;
455 return_value = _codecs_utf_32_decode_impl(module, &data, errors, final);
456
457exit:
458 /* Cleanup for data */
459 if (data.obj)
460 PyBuffer_Release(&data);
461
462 return return_value;
463}
464
465PyDoc_STRVAR(_codecs_utf_32_le_decode__doc__,
466"utf_32_le_decode($module, data, errors=None, final=False, /)\n"
467"--\n"
468"\n");
469
470#define _CODECS_UTF_32_LE_DECODE_METHODDEF \
471 {"utf_32_le_decode", (PyCFunction)_codecs_utf_32_le_decode, METH_VARARGS, _codecs_utf_32_le_decode__doc__},
472
473static PyObject *
474_codecs_utf_32_le_decode_impl(PyModuleDef *module, Py_buffer *data,
475 const char *errors, int final);
476
477static PyObject *
478_codecs_utf_32_le_decode(PyModuleDef *module, PyObject *args)
479{
480 PyObject *return_value = NULL;
481 Py_buffer data = {NULL, NULL};
482 const char *errors = NULL;
483 int final = 0;
484
485 if (!PyArg_ParseTuple(args, "y*|zi:utf_32_le_decode",
486 &data, &errors, &final))
487 goto exit;
488 return_value = _codecs_utf_32_le_decode_impl(module, &data, errors, final);
489
490exit:
491 /* Cleanup for data */
492 if (data.obj)
493 PyBuffer_Release(&data);
494
495 return return_value;
496}
497
498PyDoc_STRVAR(_codecs_utf_32_be_decode__doc__,
499"utf_32_be_decode($module, data, errors=None, final=False, /)\n"
500"--\n"
501"\n");
502
503#define _CODECS_UTF_32_BE_DECODE_METHODDEF \
504 {"utf_32_be_decode", (PyCFunction)_codecs_utf_32_be_decode, METH_VARARGS, _codecs_utf_32_be_decode__doc__},
505
506static PyObject *
507_codecs_utf_32_be_decode_impl(PyModuleDef *module, Py_buffer *data,
508 const char *errors, int final);
509
510static PyObject *
511_codecs_utf_32_be_decode(PyModuleDef *module, PyObject *args)
512{
513 PyObject *return_value = NULL;
514 Py_buffer data = {NULL, NULL};
515 const char *errors = NULL;
516 int final = 0;
517
518 if (!PyArg_ParseTuple(args, "y*|zi:utf_32_be_decode",
519 &data, &errors, &final))
520 goto exit;
521 return_value = _codecs_utf_32_be_decode_impl(module, &data, errors, final);
522
523exit:
524 /* Cleanup for data */
525 if (data.obj)
526 PyBuffer_Release(&data);
527
528 return return_value;
529}
530
531PyDoc_STRVAR(_codecs_utf_32_ex_decode__doc__,
532"utf_32_ex_decode($module, data, errors=None, byteorder=0, final=False,\n"
533" /)\n"
534"--\n"
535"\n");
536
537#define _CODECS_UTF_32_EX_DECODE_METHODDEF \
538 {"utf_32_ex_decode", (PyCFunction)_codecs_utf_32_ex_decode, METH_VARARGS, _codecs_utf_32_ex_decode__doc__},
539
540static PyObject *
541_codecs_utf_32_ex_decode_impl(PyModuleDef *module, Py_buffer *data,
542 const char *errors, int byteorder, int final);
543
544static PyObject *
545_codecs_utf_32_ex_decode(PyModuleDef *module, PyObject *args)
546{
547 PyObject *return_value = NULL;
548 Py_buffer data = {NULL, NULL};
549 const char *errors = NULL;
550 int byteorder = 0;
551 int final = 0;
552
553 if (!PyArg_ParseTuple(args, "y*|zii:utf_32_ex_decode",
554 &data, &errors, &byteorder, &final))
555 goto exit;
556 return_value = _codecs_utf_32_ex_decode_impl(module, &data, errors, byteorder, final);
557
558exit:
559 /* Cleanup for data */
560 if (data.obj)
561 PyBuffer_Release(&data);
562
563 return return_value;
564}
565
566PyDoc_STRVAR(_codecs_unicode_escape_decode__doc__,
567"unicode_escape_decode($module, data, errors=None, /)\n"
568"--\n"
569"\n");
570
571#define _CODECS_UNICODE_ESCAPE_DECODE_METHODDEF \
572 {"unicode_escape_decode", (PyCFunction)_codecs_unicode_escape_decode, METH_VARARGS, _codecs_unicode_escape_decode__doc__},
573
574static PyObject *
575_codecs_unicode_escape_decode_impl(PyModuleDef *module, Py_buffer *data,
576 const char *errors);
577
578static PyObject *
579_codecs_unicode_escape_decode(PyModuleDef *module, PyObject *args)
580{
581 PyObject *return_value = NULL;
582 Py_buffer data = {NULL, NULL};
583 const char *errors = NULL;
584
585 if (!PyArg_ParseTuple(args, "s*|z:unicode_escape_decode",
586 &data, &errors))
587 goto exit;
588 return_value = _codecs_unicode_escape_decode_impl(module, &data, errors);
589
590exit:
591 /* Cleanup for data */
592 if (data.obj)
593 PyBuffer_Release(&data);
594
595 return return_value;
596}
597
598PyDoc_STRVAR(_codecs_raw_unicode_escape_decode__doc__,
599"raw_unicode_escape_decode($module, data, errors=None, /)\n"
600"--\n"
601"\n");
602
603#define _CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF \
604 {"raw_unicode_escape_decode", (PyCFunction)_codecs_raw_unicode_escape_decode, METH_VARARGS, _codecs_raw_unicode_escape_decode__doc__},
605
606static PyObject *
607_codecs_raw_unicode_escape_decode_impl(PyModuleDef *module, Py_buffer *data,
608 const char *errors);
609
610static PyObject *
611_codecs_raw_unicode_escape_decode(PyModuleDef *module, PyObject *args)
612{
613 PyObject *return_value = NULL;
614 Py_buffer data = {NULL, NULL};
615 const char *errors = NULL;
616
617 if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode",
618 &data, &errors))
619 goto exit;
620 return_value = _codecs_raw_unicode_escape_decode_impl(module, &data, errors);
621
622exit:
623 /* Cleanup for data */
624 if (data.obj)
625 PyBuffer_Release(&data);
626
627 return return_value;
628}
629
630PyDoc_STRVAR(_codecs_latin_1_decode__doc__,
631"latin_1_decode($module, data, errors=None, /)\n"
632"--\n"
633"\n");
634
635#define _CODECS_LATIN_1_DECODE_METHODDEF \
636 {"latin_1_decode", (PyCFunction)_codecs_latin_1_decode, METH_VARARGS, _codecs_latin_1_decode__doc__},
637
638static PyObject *
639_codecs_latin_1_decode_impl(PyModuleDef *module, Py_buffer *data,
640 const char *errors);
641
642static PyObject *
643_codecs_latin_1_decode(PyModuleDef *module, PyObject *args)
644{
645 PyObject *return_value = NULL;
646 Py_buffer data = {NULL, NULL};
647 const char *errors = NULL;
648
649 if (!PyArg_ParseTuple(args, "y*|z:latin_1_decode",
650 &data, &errors))
651 goto exit;
652 return_value = _codecs_latin_1_decode_impl(module, &data, errors);
653
654exit:
655 /* Cleanup for data */
656 if (data.obj)
657 PyBuffer_Release(&data);
658
659 return return_value;
660}
661
662PyDoc_STRVAR(_codecs_ascii_decode__doc__,
663"ascii_decode($module, data, errors=None, /)\n"
664"--\n"
665"\n");
666
667#define _CODECS_ASCII_DECODE_METHODDEF \
668 {"ascii_decode", (PyCFunction)_codecs_ascii_decode, METH_VARARGS, _codecs_ascii_decode__doc__},
669
670static PyObject *
671_codecs_ascii_decode_impl(PyModuleDef *module, Py_buffer *data,
672 const char *errors);
673
674static PyObject *
675_codecs_ascii_decode(PyModuleDef *module, PyObject *args)
676{
677 PyObject *return_value = NULL;
678 Py_buffer data = {NULL, NULL};
679 const char *errors = NULL;
680
681 if (!PyArg_ParseTuple(args, "y*|z:ascii_decode",
682 &data, &errors))
683 goto exit;
684 return_value = _codecs_ascii_decode_impl(module, &data, errors);
685
686exit:
687 /* Cleanup for data */
688 if (data.obj)
689 PyBuffer_Release(&data);
690
691 return return_value;
692}
693
694PyDoc_STRVAR(_codecs_charmap_decode__doc__,
695"charmap_decode($module, data, errors=None, mapping=None, /)\n"
696"--\n"
697"\n");
698
699#define _CODECS_CHARMAP_DECODE_METHODDEF \
700 {"charmap_decode", (PyCFunction)_codecs_charmap_decode, METH_VARARGS, _codecs_charmap_decode__doc__},
701
702static PyObject *
703_codecs_charmap_decode_impl(PyModuleDef *module, Py_buffer *data,
704 const char *errors, PyObject *mapping);
705
706static PyObject *
707_codecs_charmap_decode(PyModuleDef *module, PyObject *args)
708{
709 PyObject *return_value = NULL;
710 Py_buffer data = {NULL, NULL};
711 const char *errors = NULL;
712 PyObject *mapping = NULL;
713
714 if (!PyArg_ParseTuple(args, "y*|zO:charmap_decode",
715 &data, &errors, &mapping))
716 goto exit;
717 return_value = _codecs_charmap_decode_impl(module, &data, errors, mapping);
718
719exit:
720 /* Cleanup for data */
721 if (data.obj)
722 PyBuffer_Release(&data);
723
724 return return_value;
725}
726
727#if defined(HAVE_MBCS)
728
729PyDoc_STRVAR(_codecs_mbcs_decode__doc__,
730"mbcs_decode($module, data, errors=None, final=False, /)\n"
731"--\n"
732"\n");
733
734#define _CODECS_MBCS_DECODE_METHODDEF \
735 {"mbcs_decode", (PyCFunction)_codecs_mbcs_decode, METH_VARARGS, _codecs_mbcs_decode__doc__},
736
737static PyObject *
738_codecs_mbcs_decode_impl(PyModuleDef *module, Py_buffer *data,
739 const char *errors, int final);
740
741static PyObject *
742_codecs_mbcs_decode(PyModuleDef *module, PyObject *args)
743{
744 PyObject *return_value = NULL;
745 Py_buffer data = {NULL, NULL};
746 const char *errors = NULL;
747 int final = 0;
748
749 if (!PyArg_ParseTuple(args, "y*|zi:mbcs_decode",
750 &data, &errors, &final))
751 goto exit;
752 return_value = _codecs_mbcs_decode_impl(module, &data, errors, final);
753
754exit:
755 /* Cleanup for data */
756 if (data.obj)
757 PyBuffer_Release(&data);
758
759 return return_value;
760}
761
762#endif /* defined(HAVE_MBCS) */
763
764#if defined(HAVE_MBCS)
765
766PyDoc_STRVAR(_codecs_code_page_decode__doc__,
767"code_page_decode($module, codepage, data, errors=None, final=False, /)\n"
768"--\n"
769"\n");
770
771#define _CODECS_CODE_PAGE_DECODE_METHODDEF \
772 {"code_page_decode", (PyCFunction)_codecs_code_page_decode, METH_VARARGS, _codecs_code_page_decode__doc__},
773
774static PyObject *
775_codecs_code_page_decode_impl(PyModuleDef *module, int codepage,
776 Py_buffer *data, const char *errors, int final);
777
778static PyObject *
779_codecs_code_page_decode(PyModuleDef *module, PyObject *args)
780{
781 PyObject *return_value = NULL;
782 int codepage;
783 Py_buffer data = {NULL, NULL};
784 const char *errors = NULL;
785 int final = 0;
786
787 if (!PyArg_ParseTuple(args, "iy*|zi:code_page_decode",
788 &codepage, &data, &errors, &final))
789 goto exit;
790 return_value = _codecs_code_page_decode_impl(module, codepage, &data, errors, final);
791
792exit:
793 /* Cleanup for data */
794 if (data.obj)
795 PyBuffer_Release(&data);
796
797 return return_value;
798}
799
800#endif /* defined(HAVE_MBCS) */
801
802PyDoc_STRVAR(_codecs_readbuffer_encode__doc__,
803"readbuffer_encode($module, data, errors=None, /)\n"
804"--\n"
805"\n");
806
807#define _CODECS_READBUFFER_ENCODE_METHODDEF \
808 {"readbuffer_encode", (PyCFunction)_codecs_readbuffer_encode, METH_VARARGS, _codecs_readbuffer_encode__doc__},
809
810static PyObject *
811_codecs_readbuffer_encode_impl(PyModuleDef *module, Py_buffer *data,
812 const char *errors);
813
814static PyObject *
815_codecs_readbuffer_encode(PyModuleDef *module, PyObject *args)
816{
817 PyObject *return_value = NULL;
818 Py_buffer data = {NULL, NULL};
819 const char *errors = NULL;
820
821 if (!PyArg_ParseTuple(args, "s*|z:readbuffer_encode",
822 &data, &errors))
823 goto exit;
824 return_value = _codecs_readbuffer_encode_impl(module, &data, errors);
825
826exit:
827 /* Cleanup for data */
828 if (data.obj)
829 PyBuffer_Release(&data);
830
831 return return_value;
832}
833
834PyDoc_STRVAR(_codecs_unicode_internal_encode__doc__,
835"unicode_internal_encode($module, obj, errors=None, /)\n"
836"--\n"
837"\n");
838
839#define _CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF \
840 {"unicode_internal_encode", (PyCFunction)_codecs_unicode_internal_encode, METH_VARARGS, _codecs_unicode_internal_encode__doc__},
841
842static PyObject *
843_codecs_unicode_internal_encode_impl(PyModuleDef *module, PyObject *obj,
844 const char *errors);
845
846static PyObject *
847_codecs_unicode_internal_encode(PyModuleDef *module, PyObject *args)
848{
849 PyObject *return_value = NULL;
850 PyObject *obj;
851 const char *errors = NULL;
852
853 if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
854 &obj, &errors))
855 goto exit;
856 return_value = _codecs_unicode_internal_encode_impl(module, obj, errors);
857
858exit:
859 return return_value;
860}
861
862PyDoc_STRVAR(_codecs_utf_7_encode__doc__,
863"utf_7_encode($module, str, errors=None, /)\n"
864"--\n"
865"\n");
866
867#define _CODECS_UTF_7_ENCODE_METHODDEF \
868 {"utf_7_encode", (PyCFunction)_codecs_utf_7_encode, METH_VARARGS, _codecs_utf_7_encode__doc__},
869
870static PyObject *
871_codecs_utf_7_encode_impl(PyModuleDef *module, PyObject *str,
872 const char *errors);
873
874static PyObject *
875_codecs_utf_7_encode(PyModuleDef *module, PyObject *args)
876{
877 PyObject *return_value = NULL;
878 PyObject *str;
879 const char *errors = NULL;
880
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +0300881 if (!PyArg_ParseTuple(args, "U|z:utf_7_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300882 &str, &errors))
883 goto exit;
884 return_value = _codecs_utf_7_encode_impl(module, str, errors);
885
886exit:
887 return return_value;
888}
889
890PyDoc_STRVAR(_codecs_utf_8_encode__doc__,
891"utf_8_encode($module, str, errors=None, /)\n"
892"--\n"
893"\n");
894
895#define _CODECS_UTF_8_ENCODE_METHODDEF \
896 {"utf_8_encode", (PyCFunction)_codecs_utf_8_encode, METH_VARARGS, _codecs_utf_8_encode__doc__},
897
898static PyObject *
899_codecs_utf_8_encode_impl(PyModuleDef *module, PyObject *str,
900 const char *errors);
901
902static PyObject *
903_codecs_utf_8_encode(PyModuleDef *module, PyObject *args)
904{
905 PyObject *return_value = NULL;
906 PyObject *str;
907 const char *errors = NULL;
908
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +0300909 if (!PyArg_ParseTuple(args, "U|z:utf_8_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300910 &str, &errors))
911 goto exit;
912 return_value = _codecs_utf_8_encode_impl(module, str, errors);
913
914exit:
915 return return_value;
916}
917
918PyDoc_STRVAR(_codecs_utf_16_encode__doc__,
919"utf_16_encode($module, str, errors=None, byteorder=0, /)\n"
920"--\n"
921"\n");
922
923#define _CODECS_UTF_16_ENCODE_METHODDEF \
924 {"utf_16_encode", (PyCFunction)_codecs_utf_16_encode, METH_VARARGS, _codecs_utf_16_encode__doc__},
925
926static PyObject *
927_codecs_utf_16_encode_impl(PyModuleDef *module, PyObject *str,
928 const char *errors, int byteorder);
929
930static PyObject *
931_codecs_utf_16_encode(PyModuleDef *module, PyObject *args)
932{
933 PyObject *return_value = NULL;
934 PyObject *str;
935 const char *errors = NULL;
936 int byteorder = 0;
937
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +0300938 if (!PyArg_ParseTuple(args, "U|zi:utf_16_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300939 &str, &errors, &byteorder))
940 goto exit;
941 return_value = _codecs_utf_16_encode_impl(module, str, errors, byteorder);
942
943exit:
944 return return_value;
945}
946
947PyDoc_STRVAR(_codecs_utf_16_le_encode__doc__,
948"utf_16_le_encode($module, str, errors=None, /)\n"
949"--\n"
950"\n");
951
952#define _CODECS_UTF_16_LE_ENCODE_METHODDEF \
953 {"utf_16_le_encode", (PyCFunction)_codecs_utf_16_le_encode, METH_VARARGS, _codecs_utf_16_le_encode__doc__},
954
955static PyObject *
956_codecs_utf_16_le_encode_impl(PyModuleDef *module, PyObject *str,
957 const char *errors);
958
959static PyObject *
960_codecs_utf_16_le_encode(PyModuleDef *module, PyObject *args)
961{
962 PyObject *return_value = NULL;
963 PyObject *str;
964 const char *errors = NULL;
965
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +0300966 if (!PyArg_ParseTuple(args, "U|z:utf_16_le_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300967 &str, &errors))
968 goto exit;
969 return_value = _codecs_utf_16_le_encode_impl(module, str, errors);
970
971exit:
972 return return_value;
973}
974
975PyDoc_STRVAR(_codecs_utf_16_be_encode__doc__,
976"utf_16_be_encode($module, str, errors=None, /)\n"
977"--\n"
978"\n");
979
980#define _CODECS_UTF_16_BE_ENCODE_METHODDEF \
981 {"utf_16_be_encode", (PyCFunction)_codecs_utf_16_be_encode, METH_VARARGS, _codecs_utf_16_be_encode__doc__},
982
983static PyObject *
984_codecs_utf_16_be_encode_impl(PyModuleDef *module, PyObject *str,
985 const char *errors);
986
987static PyObject *
988_codecs_utf_16_be_encode(PyModuleDef *module, PyObject *args)
989{
990 PyObject *return_value = NULL;
991 PyObject *str;
992 const char *errors = NULL;
993
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +0300994 if (!PyArg_ParseTuple(args, "U|z:utf_16_be_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300995 &str, &errors))
996 goto exit;
997 return_value = _codecs_utf_16_be_encode_impl(module, str, errors);
998
999exit:
1000 return return_value;
1001}
1002
1003PyDoc_STRVAR(_codecs_utf_32_encode__doc__,
1004"utf_32_encode($module, str, errors=None, byteorder=0, /)\n"
1005"--\n"
1006"\n");
1007
1008#define _CODECS_UTF_32_ENCODE_METHODDEF \
1009 {"utf_32_encode", (PyCFunction)_codecs_utf_32_encode, METH_VARARGS, _codecs_utf_32_encode__doc__},
1010
1011static PyObject *
1012_codecs_utf_32_encode_impl(PyModuleDef *module, PyObject *str,
1013 const char *errors, int byteorder);
1014
1015static PyObject *
1016_codecs_utf_32_encode(PyModuleDef *module, PyObject *args)
1017{
1018 PyObject *return_value = NULL;
1019 PyObject *str;
1020 const char *errors = NULL;
1021 int byteorder = 0;
1022
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001023 if (!PyArg_ParseTuple(args, "U|zi:utf_32_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001024 &str, &errors, &byteorder))
1025 goto exit;
1026 return_value = _codecs_utf_32_encode_impl(module, str, errors, byteorder);
1027
1028exit:
1029 return return_value;
1030}
1031
1032PyDoc_STRVAR(_codecs_utf_32_le_encode__doc__,
1033"utf_32_le_encode($module, str, errors=None, /)\n"
1034"--\n"
1035"\n");
1036
1037#define _CODECS_UTF_32_LE_ENCODE_METHODDEF \
1038 {"utf_32_le_encode", (PyCFunction)_codecs_utf_32_le_encode, METH_VARARGS, _codecs_utf_32_le_encode__doc__},
1039
1040static PyObject *
1041_codecs_utf_32_le_encode_impl(PyModuleDef *module, PyObject *str,
1042 const char *errors);
1043
1044static PyObject *
1045_codecs_utf_32_le_encode(PyModuleDef *module, PyObject *args)
1046{
1047 PyObject *return_value = NULL;
1048 PyObject *str;
1049 const char *errors = NULL;
1050
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001051 if (!PyArg_ParseTuple(args, "U|z:utf_32_le_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001052 &str, &errors))
1053 goto exit;
1054 return_value = _codecs_utf_32_le_encode_impl(module, str, errors);
1055
1056exit:
1057 return return_value;
1058}
1059
1060PyDoc_STRVAR(_codecs_utf_32_be_encode__doc__,
1061"utf_32_be_encode($module, str, errors=None, /)\n"
1062"--\n"
1063"\n");
1064
1065#define _CODECS_UTF_32_BE_ENCODE_METHODDEF \
1066 {"utf_32_be_encode", (PyCFunction)_codecs_utf_32_be_encode, METH_VARARGS, _codecs_utf_32_be_encode__doc__},
1067
1068static PyObject *
1069_codecs_utf_32_be_encode_impl(PyModuleDef *module, PyObject *str,
1070 const char *errors);
1071
1072static PyObject *
1073_codecs_utf_32_be_encode(PyModuleDef *module, PyObject *args)
1074{
1075 PyObject *return_value = NULL;
1076 PyObject *str;
1077 const char *errors = NULL;
1078
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001079 if (!PyArg_ParseTuple(args, "U|z:utf_32_be_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001080 &str, &errors))
1081 goto exit;
1082 return_value = _codecs_utf_32_be_encode_impl(module, str, errors);
1083
1084exit:
1085 return return_value;
1086}
1087
1088PyDoc_STRVAR(_codecs_unicode_escape_encode__doc__,
1089"unicode_escape_encode($module, str, errors=None, /)\n"
1090"--\n"
1091"\n");
1092
1093#define _CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF \
1094 {"unicode_escape_encode", (PyCFunction)_codecs_unicode_escape_encode, METH_VARARGS, _codecs_unicode_escape_encode__doc__},
1095
1096static PyObject *
1097_codecs_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str,
1098 const char *errors);
1099
1100static PyObject *
1101_codecs_unicode_escape_encode(PyModuleDef *module, PyObject *args)
1102{
1103 PyObject *return_value = NULL;
1104 PyObject *str;
1105 const char *errors = NULL;
1106
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001107 if (!PyArg_ParseTuple(args, "U|z:unicode_escape_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001108 &str, &errors))
1109 goto exit;
1110 return_value = _codecs_unicode_escape_encode_impl(module, str, errors);
1111
1112exit:
1113 return return_value;
1114}
1115
1116PyDoc_STRVAR(_codecs_raw_unicode_escape_encode__doc__,
1117"raw_unicode_escape_encode($module, str, errors=None, /)\n"
1118"--\n"
1119"\n");
1120
1121#define _CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF \
1122 {"raw_unicode_escape_encode", (PyCFunction)_codecs_raw_unicode_escape_encode, METH_VARARGS, _codecs_raw_unicode_escape_encode__doc__},
1123
1124static PyObject *
1125_codecs_raw_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str,
1126 const char *errors);
1127
1128static PyObject *
1129_codecs_raw_unicode_escape_encode(PyModuleDef *module, PyObject *args)
1130{
1131 PyObject *return_value = NULL;
1132 PyObject *str;
1133 const char *errors = NULL;
1134
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001135 if (!PyArg_ParseTuple(args, "U|z:raw_unicode_escape_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001136 &str, &errors))
1137 goto exit;
1138 return_value = _codecs_raw_unicode_escape_encode_impl(module, str, errors);
1139
1140exit:
1141 return return_value;
1142}
1143
1144PyDoc_STRVAR(_codecs_latin_1_encode__doc__,
1145"latin_1_encode($module, str, errors=None, /)\n"
1146"--\n"
1147"\n");
1148
1149#define _CODECS_LATIN_1_ENCODE_METHODDEF \
1150 {"latin_1_encode", (PyCFunction)_codecs_latin_1_encode, METH_VARARGS, _codecs_latin_1_encode__doc__},
1151
1152static PyObject *
1153_codecs_latin_1_encode_impl(PyModuleDef *module, PyObject *str,
1154 const char *errors);
1155
1156static PyObject *
1157_codecs_latin_1_encode(PyModuleDef *module, PyObject *args)
1158{
1159 PyObject *return_value = NULL;
1160 PyObject *str;
1161 const char *errors = NULL;
1162
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001163 if (!PyArg_ParseTuple(args, "U|z:latin_1_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001164 &str, &errors))
1165 goto exit;
1166 return_value = _codecs_latin_1_encode_impl(module, str, errors);
1167
1168exit:
1169 return return_value;
1170}
1171
1172PyDoc_STRVAR(_codecs_ascii_encode__doc__,
1173"ascii_encode($module, str, errors=None, /)\n"
1174"--\n"
1175"\n");
1176
1177#define _CODECS_ASCII_ENCODE_METHODDEF \
1178 {"ascii_encode", (PyCFunction)_codecs_ascii_encode, METH_VARARGS, _codecs_ascii_encode__doc__},
1179
1180static PyObject *
1181_codecs_ascii_encode_impl(PyModuleDef *module, PyObject *str,
1182 const char *errors);
1183
1184static PyObject *
1185_codecs_ascii_encode(PyModuleDef *module, PyObject *args)
1186{
1187 PyObject *return_value = NULL;
1188 PyObject *str;
1189 const char *errors = NULL;
1190
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001191 if (!PyArg_ParseTuple(args, "U|z:ascii_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001192 &str, &errors))
1193 goto exit;
1194 return_value = _codecs_ascii_encode_impl(module, str, errors);
1195
1196exit:
1197 return return_value;
1198}
1199
1200PyDoc_STRVAR(_codecs_charmap_encode__doc__,
1201"charmap_encode($module, str, errors=None, mapping=None, /)\n"
1202"--\n"
1203"\n");
1204
1205#define _CODECS_CHARMAP_ENCODE_METHODDEF \
1206 {"charmap_encode", (PyCFunction)_codecs_charmap_encode, METH_VARARGS, _codecs_charmap_encode__doc__},
1207
1208static PyObject *
1209_codecs_charmap_encode_impl(PyModuleDef *module, PyObject *str,
1210 const char *errors, PyObject *mapping);
1211
1212static PyObject *
1213_codecs_charmap_encode(PyModuleDef *module, PyObject *args)
1214{
1215 PyObject *return_value = NULL;
1216 PyObject *str;
1217 const char *errors = NULL;
1218 PyObject *mapping = NULL;
1219
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001220 if (!PyArg_ParseTuple(args, "U|zO:charmap_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001221 &str, &errors, &mapping))
1222 goto exit;
1223 return_value = _codecs_charmap_encode_impl(module, str, errors, mapping);
1224
1225exit:
1226 return return_value;
1227}
1228
1229PyDoc_STRVAR(_codecs_charmap_build__doc__,
1230"charmap_build($module, map, /)\n"
1231"--\n"
1232"\n");
1233
1234#define _CODECS_CHARMAP_BUILD_METHODDEF \
1235 {"charmap_build", (PyCFunction)_codecs_charmap_build, METH_O, _codecs_charmap_build__doc__},
1236
1237static PyObject *
1238_codecs_charmap_build_impl(PyModuleDef *module, PyObject *map);
1239
1240static PyObject *
1241_codecs_charmap_build(PyModuleDef *module, PyObject *arg)
1242{
1243 PyObject *return_value = NULL;
1244 PyObject *map;
1245
1246 if (!PyArg_Parse(arg, "U:charmap_build", &map))
1247 goto exit;
1248 return_value = _codecs_charmap_build_impl(module, map);
1249
1250exit:
1251 return return_value;
1252}
1253
1254#if defined(HAVE_MBCS)
1255
1256PyDoc_STRVAR(_codecs_mbcs_encode__doc__,
1257"mbcs_encode($module, str, errors=None, /)\n"
1258"--\n"
1259"\n");
1260
1261#define _CODECS_MBCS_ENCODE_METHODDEF \
1262 {"mbcs_encode", (PyCFunction)_codecs_mbcs_encode, METH_VARARGS, _codecs_mbcs_encode__doc__},
1263
1264static PyObject *
1265_codecs_mbcs_encode_impl(PyModuleDef *module, PyObject *str,
1266 const char *errors);
1267
1268static PyObject *
1269_codecs_mbcs_encode(PyModuleDef *module, PyObject *args)
1270{
1271 PyObject *return_value = NULL;
1272 PyObject *str;
1273 const char *errors = NULL;
1274
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001275 if (!PyArg_ParseTuple(args, "U|z:mbcs_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001276 &str, &errors))
1277 goto exit;
1278 return_value = _codecs_mbcs_encode_impl(module, str, errors);
1279
1280exit:
1281 return return_value;
1282}
1283
1284#endif /* defined(HAVE_MBCS) */
1285
1286#if defined(HAVE_MBCS)
1287
1288PyDoc_STRVAR(_codecs_code_page_encode__doc__,
1289"code_page_encode($module, code_page, str, errors=None, /)\n"
1290"--\n"
1291"\n");
1292
1293#define _CODECS_CODE_PAGE_ENCODE_METHODDEF \
1294 {"code_page_encode", (PyCFunction)_codecs_code_page_encode, METH_VARARGS, _codecs_code_page_encode__doc__},
1295
1296static PyObject *
1297_codecs_code_page_encode_impl(PyModuleDef *module, int code_page,
1298 PyObject *str, const char *errors);
1299
1300static PyObject *
1301_codecs_code_page_encode(PyModuleDef *module, PyObject *args)
1302{
1303 PyObject *return_value = NULL;
1304 int code_page;
1305 PyObject *str;
1306 const char *errors = NULL;
1307
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001308 if (!PyArg_ParseTuple(args, "iU|z:code_page_encode",
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001309 &code_page, &str, &errors))
1310 goto exit;
1311 return_value = _codecs_code_page_encode_impl(module, code_page, str, errors);
1312
1313exit:
1314 return return_value;
1315}
1316
1317#endif /* defined(HAVE_MBCS) */
1318
1319PyDoc_STRVAR(_codecs_register_error__doc__,
1320"register_error($module, errors, handler, /)\n"
1321"--\n"
1322"\n"
1323"Register the specified error handler under the name errors.\n"
1324"\n"
1325"handler must be a callable object, that will be called with an exception\n"
1326"instance containing information about the location of the encoding/decoding\n"
1327"error and must return a (replacement, new position) tuple.");
1328
1329#define _CODECS_REGISTER_ERROR_METHODDEF \
1330 {"register_error", (PyCFunction)_codecs_register_error, METH_VARARGS, _codecs_register_error__doc__},
1331
1332static PyObject *
1333_codecs_register_error_impl(PyModuleDef *module, const char *errors,
1334 PyObject *handler);
1335
1336static PyObject *
1337_codecs_register_error(PyModuleDef *module, PyObject *args)
1338{
1339 PyObject *return_value = NULL;
1340 const char *errors;
1341 PyObject *handler;
1342
1343 if (!PyArg_ParseTuple(args, "sO:register_error",
1344 &errors, &handler))
1345 goto exit;
1346 return_value = _codecs_register_error_impl(module, errors, handler);
1347
1348exit:
1349 return return_value;
1350}
1351
1352PyDoc_STRVAR(_codecs_lookup_error__doc__,
1353"lookup_error($module, name, /)\n"
1354"--\n"
1355"\n"
1356"lookup_error(errors) -> handler\n"
1357"\n"
1358"Return the error handler for the specified error handling name or raise a\n"
1359"LookupError, if no handler exists under this name.");
1360
1361#define _CODECS_LOOKUP_ERROR_METHODDEF \
1362 {"lookup_error", (PyCFunction)_codecs_lookup_error, METH_O, _codecs_lookup_error__doc__},
1363
1364static PyObject *
1365_codecs_lookup_error_impl(PyModuleDef *module, const char *name);
1366
1367static PyObject *
1368_codecs_lookup_error(PyModuleDef *module, PyObject *arg)
1369{
1370 PyObject *return_value = NULL;
1371 const char *name;
1372
1373 if (!PyArg_Parse(arg, "s:lookup_error", &name))
1374 goto exit;
1375 return_value = _codecs_lookup_error_impl(module, name);
1376
1377exit:
1378 return return_value;
1379}
1380
1381#ifndef _CODECS_MBCS_DECODE_METHODDEF
1382 #define _CODECS_MBCS_DECODE_METHODDEF
1383#endif /* !defined(_CODECS_MBCS_DECODE_METHODDEF) */
1384
1385#ifndef _CODECS_CODE_PAGE_DECODE_METHODDEF
1386 #define _CODECS_CODE_PAGE_DECODE_METHODDEF
1387#endif /* !defined(_CODECS_CODE_PAGE_DECODE_METHODDEF) */
1388
1389#ifndef _CODECS_MBCS_ENCODE_METHODDEF
1390 #define _CODECS_MBCS_ENCODE_METHODDEF
1391#endif /* !defined(_CODECS_MBCS_ENCODE_METHODDEF) */
1392
1393#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
1394 #define _CODECS_CODE_PAGE_ENCODE_METHODDEF
1395#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001396/*[clinic end generated code: output=04007a13c8387689 input=a9049054013a1b77]*/