Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10)

Delta Between Two Patch Sets: Modules/_codecsmodule.c

Issue 20173: Derby #4: Convert 53 sites to Argument Clinic across 5 files
Left Patch Set: Created 6 years, 4 months ago
Right Patch Set: Created 5 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/clinic/_codecsmodule.c.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* ------------------------------------------------------------------------ 1 /* ------------------------------------------------------------------------
2 2
3 _codecs -- Provides access to the codec registry and the builtin 3 _codecs -- Provides access to the codec registry and the builtin
4 codecs. 4 codecs.
5 5
6 This module should never be imported directly. The standard library 6 This module should never be imported directly. The standard library
7 module "codecs" wraps this builtin module for use within Python. 7 module "codecs" wraps this builtin module for use within Python.
8 8
9 The codec registry is accessible via: 9 The codec registry is accessible via:
10 10
(...skipping 26 matching lines...) Expand all
37 37
38 #define PY_SSIZE_T_CLEAN 38 #define PY_SSIZE_T_CLEAN
39 #include "Python.h" 39 #include "Python.h"
40 40
41 #ifdef MS_WINDOWS 41 #ifdef MS_WINDOWS
42 #include <windows.h> 42 #include <windows.h>
43 #endif 43 #endif
44 44
45 /*[clinic input] 45 /*[clinic input]
46 module _codecs 46 module _codecs
47 class _codecs.Codecs 47 [clinic start generated code]*/
48 [clinic start generated code]*/ 48 /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e1390e3da3cb9deb]*/
49 /*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709] */ 49
50 #include "clinic/_codecsmodule.c.h"
50 51
51 /* --- Registry ----------------------------------------------------------- */ 52 /* --- Registry ----------------------------------------------------------- */
52 53
53 PyDoc_STRVAR(register__doc__, 54 /*[clinic input]
54 "register(search_function)\n\ 55 _codecs.register
55 \n\ 56 search_function: object
56 Register a codec search function. Search functions are expected to take\n\ 57 /
57 one argument, the encoding name in all lower case letters, and return\n\ 58
58 a tuple of functions (encoder, decoder, stream_reader, stream_writer)\n\ 59 Register a codec search function.
59 (or a CodecInfo object)."); 60
60 61 Search functions are expected to take one argument, the encoding name in
61 static 62 all lower case letters, and either return None, or a tuple of functions
62 PyObject *codec_register(PyObject *self, PyObject *search_function) 63 (encoder, decoder, stream_reader, stream_writer) (or a CodecInfo object).
64 [clinic start generated code]*/
65
66 static PyObject *
67 _codecs_register(PyModuleDef *module, PyObject *search_function)
68 /*[clinic end generated code: output=d17608b6ad380eb8 input=369578467955cae4]*/
63 { 69 {
64 if (PyCodec_Register(search_function)) 70 if (PyCodec_Register(search_function))
65 return NULL; 71 return NULL;
66 72
67 Py_RETURN_NONE; 73 Py_RETURN_NONE;
68 } 74 }
69 75
70 /*[clinic input] 76 /*[clinic input]
71 _codecs.Codecs.lookup 77 _codecs.lookup
72 encoding: str 78 encoding: str
73 / 79 /
74 80
75 Looks up an encoding. 81 Looks up a codec tuple in the Python codec registry and returns a CodecInfo obje ct.
76 82 [clinic start generated code]*/
77 Looks up a codec tuple in the Python codec registry and returns a CodecInfo 83
78 object. 84 static PyObject *
79 [clinic start generated code]*/ 85 _codecs_lookup_impl(PyModuleDef *module, const char *encoding)
80 86 /*[clinic end generated code: output=798e41aff0c04ef6 input=3c572c0db3febe9c]*/
81 PyDoc_STRVAR(_codecs_Codecs_lookup__doc__,
82 "lookup(encoding)\n"
83 "Looks up an encoding.\n"
84 "\n"
85 "Looks up a codec tuple in the Python codec registry and returns a CodecInfo\n"
86 "object.");
87
88 #define _CODECS_CODECS_LOOKUP_METHODDEF \
89 {"lookup", (PyCFunction)_codecs_Codecs_lookup, METH_VARARGS, _codecs_Codecs_ lookup__doc__},
90
91 static PyObject *
92 _codecs_Codecs_lookup_impl(PyObject *self, const char *encoding);
93
94 static PyObject *
95 _codecs_Codecs_lookup(PyObject *self, PyObject *args)
96 {
97 PyObject *return_value = NULL;
98 const char *encoding;
99
100 if (!PyArg_ParseTuple(args,
101 "s:lookup",
102 &encoding))
103 goto exit;
104 return_value = _codecs_Codecs_lookup_impl(self, encoding);
105
106 exit:
107 return return_value;
108 }
109
110 static PyObject *
111 _codecs_Codecs_lookup_impl(PyObject *self, const char *encoding)
112 /*[clinic end generated code: checksum=b68ced685fd46f0cc233b29e343223b4eaac86d7] */
113 { 87 {
114 return _PyCodec_Lookup(encoding); 88 return _PyCodec_Lookup(encoding);
115 } 89 }
116 90
117 /*[clinic input] 91 /*[clinic input]
118 _codecs.Codecs.encode 92 _codecs.encode
119 obj: object 93 obj: object
120 [ 94 encoding: str(c_default="NULL") = "utf-8"
121 encoding: str 95 errors: str(c_default="NULL") = "strict"
122 [
123 errors: str
124 ]
125 ]
126 /
127 96
128 Encodes obj using the codec registered for encoding. 97 Encodes obj using the codec registered for encoding.
129 98
130 encoding defaults to the default encoding. errors may be given to set a 99 encoding defaults to the default encoding. errors may be given to set a
131 different error handling scheme. Default is 'strict' meaning that encoding 100 different error handling scheme. Default is 'strict' meaning that encoding
132 errors raise a ValueError. Other possible values are 'ignore', 'replace' and 101 errors raise a ValueError. Other possible values are 'ignore', 'replace'
133 'xmlcharrefreplace' as well as any other name registered with 102 and 'xmlcharrefreplace' as well as any other name registered with
134 codecs.register_error that can handle ValueErrors. 103 codecs.register_error that can handle ValueErrors.
135 [clinic start generated code]*/ 104 [clinic start generated code]*/
136 105
137 PyDoc_STRVAR(_codecs_Codecs_encode__doc__, 106 static PyObject *
138 "encode(obj, [encoding, [errors]])\n" 107 _codecs_encode_impl(PyModuleDef *module, PyObject *obj, const char *encoding,
139 "Encodes obj using the codec registered for encoding.\n" 108 const char *errors)
140 "\n" 109 /*[clinic end generated code: output=5c073f62249c8d7c input=cb1f62cf8d9e2a2c]*/
141 "encoding defaults to the default encoding. errors may be given to set a\n"
142 "different error handling scheme. Default is \'strict\' meaning that encoding\n"
143 "errors raise a ValueError. Other possible values are \'ignore\', \'replace\' an d\n"
144 "\'xmlcharrefreplace\' as well as any other name registered with\n"
145 "codecs.register_error that can handle ValueErrors.");
146
147 #define _CODECS_CODECS_ENCODE_METHODDEF \
148 {"encode", (PyCFunction)_codecs_Codecs_encode, METH_VARARGS, _codecs_Codecs_ encode__doc__},
149
150 static PyObject *
151 _codecs_Codecs_encode_impl(PyObject *self, PyObject *obj, int group_right_1, con st char *encoding, int group_right_2, const char *errors);
152
153 static PyObject *
154 _codecs_Codecs_encode(PyObject *self, PyObject *args)
155 {
156 PyObject *return_value = NULL;
157 PyObject *obj;
158 int group_right_1 = 0;
159 const char *encoding = NULL;
160 int group_right_2 = 0;
161 const char *errors = NULL;
162
163 switch (PyTuple_Size(args)) {
164 case 1:
165 if (!PyArg_ParseTuple(args, "O:encode", &obj))
166 return NULL;
167 break;
168 case 2:
169 if (!PyArg_ParseTuple(args, "Os:encode", &obj, &encoding))
170 return NULL;
171 group_right_1 = 1;
172 break;
173 case 3:
174 if (!PyArg_ParseTuple(args, "Oss:encode", &obj, &encoding, &errors))
175 return NULL;
176 group_right_1 = 1;
177 group_right_2 = 1;
178 break;
179 default:
180 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.encode requires 1 t o 3 arguments");
181 return NULL;
182 }
183 return_value = _codecs_Codecs_encode_impl(self, obj, group_right_1, encoding , group_right_2, errors);
184
185 return return_value;
186 }
187
188 static PyObject *
189 _codecs_Codecs_encode_impl(PyObject *self, PyObject *obj, int group_right_1, con st char *encoding, int group_right_2, const char *errors)
190 /*[clinic end generated code: checksum=5e09245ea83ae503ab82e658194a8b11713f9087] */
191 { 110 {
192 if (encoding == NULL) 111 if (encoding == NULL)
193 encoding = PyUnicode_GetDefaultEncoding(); 112 encoding = PyUnicode_GetDefaultEncoding();
194 113
195 /* Encode via the codec registry */ 114 /* Encode via the codec registry */
196 return PyCodec_Encode(obj, encoding, errors); 115 return PyCodec_Encode(obj, encoding, errors);
197 } 116 }
198 117
199 /*[clinic input] 118 /*[clinic input]
200 _codecs.Codecs.decode 119 _codecs.decode
201 obj: object 120 obj: object
202 [ 121 encoding: str(c_default="NULL") = "utf-8"
larry 2015/04/16 23:37:04 If #23967 is accepted, the Python default should b
storchaka 2015/04/17 19:34:04 It is always "utf-8" in Python 3. sys.getdefaulten
larry 2015/04/22 07:17:32 sys.getdefaultencoding() is not deprecated in the
storchaka 2015/04/23 12:07:32 PyUnicode_GetDefaultEncoding() just returns "utf-8
203 encoding: str 122 errors: str(c_default="NULL") = "strict"
204 [
205 errors: str
206 ]
207 ]
208 /
209 123
210 Decodes obj using the codec registered for encoding. 124 Decodes obj using the codec registered for encoding.
211 125
212 encoding defaults to the default encoding. errors may be given to set a 126 encoding defaults to the default encoding. errors may be given to set a
213 different error handling scheme. Default is 'strict' meaning that encoding 127 different error handling scheme. Default is 'strict' meaning that encoding
214 errors raise a ValueError. Other possible values are 'ignore' and 'replace' 128 errors raise a ValueError. Other possible values are 'ignore' and 'replace'
215 as well as any other name registered with codecs.register_error that is 129 as well as any other name registered with codecs.register_error that is able
216 able to handle ValueErrors. 130 to handle ValueErrors.
217 [clinic start generated code]*/ 131 [clinic start generated code]*/
218 132
219 PyDoc_STRVAR(_codecs_Codecs_decode__doc__, 133 static PyObject *
220 "decode(obj, [encoding, [errors]])\n" 134 _codecs_decode_impl(PyModuleDef *module, PyObject *obj, const char *encoding,
221 "Decodes obj using the codec registered for encoding.\n" 135 const char *errors)
222 "\n" 136 /*[clinic end generated code: output=c81cbf6189a7f878 input=9d04293156021886]*/
223 "encoding defaults to the default encoding. errors may be given to set a\n"
224 "different error handling scheme. Default is \'strict\' meaning that encoding\n"
225 "errors raise a ValueError. Other possible values are \'ignore\' and \'replace\' \n"
226 "as well as any other name registered with codecs.register_error that is\n"
227 "able to handle ValueErrors.");
228
229 #define _CODECS_CODECS_DECODE_METHODDEF \
230 {"decode", (PyCFunction)_codecs_Codecs_decode, METH_VARARGS, _codecs_Codecs_ decode__doc__},
231
232 static PyObject *
233 _codecs_Codecs_decode_impl(PyObject *self, PyObject *obj, int group_right_1, con st char *encoding, int group_right_2, const char *errors);
234
235 static PyObject *
236 _codecs_Codecs_decode(PyObject *self, PyObject *args)
237 {
238 PyObject *return_value = NULL;
239 PyObject *obj;
240 int group_right_1 = 0;
241 const char *encoding = NULL;
242 int group_right_2 = 0;
243 const char *errors = NULL;
244
245 switch (PyTuple_Size(args)) {
246 case 1:
247 if (!PyArg_ParseTuple(args, "O:decode", &obj))
248 return NULL;
249 break;
250 case 2:
251 if (!PyArg_ParseTuple(args, "Os:decode", &obj, &encoding))
252 return NULL;
253 group_right_1 = 1;
254 break;
255 case 3:
256 if (!PyArg_ParseTuple(args, "Oss:decode", &obj, &encoding, &errors))
257 return NULL;
258 group_right_1 = 1;
259 group_right_2 = 1;
260 break;
261 default:
262 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.decode requires 1 t o 3 arguments");
263 return NULL;
264 }
265 return_value = _codecs_Codecs_decode_impl(self, obj, group_right_1, encoding , group_right_2, errors);
266
267 return return_value;
268 }
269
270 static PyObject *
271 _codecs_Codecs_decode_impl(PyObject *self, PyObject *obj, int group_right_1, con st char *encoding, int group_right_2, const char *errors)
272 /*[clinic end generated code: checksum=26e9991555f0b60c6eb70d7408b027d788a338d4] */
273 { 137 {
274 if (encoding == NULL) 138 if (encoding == NULL)
275 encoding = PyUnicode_GetDefaultEncoding(); 139 encoding = PyUnicode_GetDefaultEncoding();
276 140
277 /* Decode via the codec registry */ 141 /* Decode via the codec registry */
278 return PyCodec_Decode(obj, encoding, errors); 142 return PyCodec_Decode(obj, encoding, errors);
279 } 143 }
280 144
281 /* --- Helpers ------------------------------------------------------------ */ 145 /* --- Helpers ------------------------------------------------------------ */
282 146
147 /*[clinic input]
148 _codecs._forget_codec
149
150 encoding: str
151 /
152
153 Purge the named codec from the internal codec lookup cache
154 [clinic start generated code]*/
155
156 static PyObject *
157 _codecs__forget_codec_impl(PyModuleDef *module, const char *encoding)
158 /*[clinic end generated code: output=b56a9b99d2d28080 input=18d5d92d0e386c38]*/
159 {
160 if (_PyCodec_Forget(encoding) < 0) {
161 return NULL;
162 };
163 Py_RETURN_NONE;
164 }
165
283 static 166 static
284 PyObject *codec_tuple(PyObject *unicode, 167 PyObject *codec_tuple(PyObject *decoded,
285 Py_ssize_t len) 168 Py_ssize_t len)
286 { 169 {
287 PyObject *v; 170 if (decoded == NULL)
288 if (unicode == NULL) 171 return NULL;
289 return NULL; 172 return Py_BuildValue("Nn", decoded, len);
290 v = Py_BuildValue("On", unicode, len);
291 Py_DECREF(unicode);
292 return v;
293 } 173 }
294 174
295 /* --- String codecs ------------------------------------------------------ */ 175 /* --- String codecs ------------------------------------------------------ */
296 /*[clinic input] 176 /*[clinic input]
297 _codecs.Codecs.escape_decode 177 _codecs.escape_decode
298 data: str(length=True) 178 data: Py_buffer(types={'str', 'buffer'})
299 [ 179 errors: str(nullable=True) = NULL
300 errors: str(nullable=True) 180 /
301 ] 181 [clinic start generated code]*/
302 / 182
303 [clinic start generated code]*/ 183 static PyObject *
304 184 _codecs_escape_decode_impl(PyModuleDef *module, Py_buffer *data,
305 PyDoc_STRVAR(_codecs_Codecs_escape_decode__doc__, 185 const char *errors)
306 "escape_decode(data, [errors])"); 186 /*[clinic end generated code: output=648fa3e78d03e658 input=f373087451274bbb]*/
307 187 {
308 #define _CODECS_CODECS_ESCAPE_DECODE_METHODDEF \ 188 PyObject *decoded = PyBytes_DecodeEscape(data->buf, data->len,
309 {"escape_decode", (PyCFunction)_codecs_Codecs_escape_decode, METH_VARARGS, _ codecs_Codecs_escape_decode__doc__}, 189 errors, 0, NULL);
310 190 return codec_tuple(decoded, data->len);
311 static PyObject * 191 }
312 _codecs_Codecs_escape_decode_impl(PyObject *self, const char *data, Py_ssize_cle an_t data_length, int group_right_1, const char *errors); 192
313 193 /*[clinic input]
314 static PyObject * 194 _codecs.escape_encode
315 _codecs_Codecs_escape_decode(PyObject *self, PyObject *args) 195 data: object(subclass_of='&PyBytes_Type')
larry 2015/04/16 23:37:04 Isn't this exactly the same as the PyBytesObject c
storchaka 2015/04/17 19:34:04 Indeed. And there are similar misuses of the "O!"
316 { 196 errors: str(nullable=True) = NULL
317 PyObject *return_value = NULL; 197 /
318 const char *data; 198 [clinic start generated code]*/
319 Py_ssize_clean_t data_length; 199
320 int group_right_1 = 0; 200 static PyObject *
321 const char *errors = NULL; 201 _codecs_escape_encode_impl(PyModuleDef *module, PyObject *data,
322 202 const char *errors)
323 switch (PyTuple_Size(args)) { 203 /*[clinic end generated code: output=fcd6f34fe4111c50 input=995ec13d87247ec7]*/
324 case 1:
325 if (!PyArg_ParseTuple(args, "s#:escape_decode", &data, &data_length) )
326 return NULL;
327 break;
328 case 2:
329 if (!PyArg_ParseTuple(args, "s#z:escape_decode", &data, &data_length , &errors))
330 return NULL;
331 group_right_1 = 1;
332 break;
333 default:
334 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.escape_decode requi res 1 to 2 arguments");
335 return NULL;
336 }
337 return_value = _codecs_Codecs_escape_decode_impl(self, data, data_length, gr oup_right_1, errors);
338
339 return return_value;
340 }
341
342 static PyObject *
343 _codecs_Codecs_escape_decode_impl(PyObject *self, const char *data, Py_ssize_cle an_t data_length, int group_right_1, const char *errors)
344 /*[clinic end generated code: checksum=2ac63e14d21c21cabf3f0cac826d6e02c16b4d8b] */
345 {
346 return codec_tuple(PyBytes_DecodeEscape(data, data_length, errors, 0, NULL),
347 data_length);
348 }
349
350 /*[clinic input]
351 _codecs.Codecs.escape_encode
352 str: object(subclass_of='&PyBytes_Type')
353 [
354 errors: str(nullable=True)
355 ]
356 /
357 [clinic start generated code]*/
358
359 PyDoc_STRVAR(_codecs_Codecs_escape_encode__doc__,
360 "escape_encode(str, [errors])");
361
362 #define _CODECS_CODECS_ESCAPE_ENCODE_METHODDEF \
363 {"escape_encode", (PyCFunction)_codecs_Codecs_escape_encode, METH_VARARGS, _ codecs_Codecs_escape_encode__doc__},
364
365 static PyObject *
366 _codecs_Codecs_escape_encode_impl(PyObject *self, PyObject *str, int group_right _1, const char *errors);
367
368 static PyObject *
369 _codecs_Codecs_escape_encode(PyObject *self, PyObject *args)
370 {
371 PyObject *return_value = NULL;
372 PyObject *str;
373 int group_right_1 = 0;
374 const char *errors = NULL;
375
376 switch (PyTuple_Size(args)) {
377 case 1:
378 if (!PyArg_ParseTuple(args, "O!:escape_encode", &PyBytes_Type, &str) )
379 return NULL;
380 break;
381 case 2:
382 if (!PyArg_ParseTuple(args, "O!z:escape_encode", &PyBytes_Type, &str , &errors))
383 return NULL;
384 group_right_1 = 1;
385 break;
386 default:
387 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.escape_encode requi res 1 to 2 arguments");
388 return NULL;
389 }
390 return_value = _codecs_Codecs_escape_encode_impl(self, str, group_right_1, e rrors);
391
392 return return_value;
393 }
394
395 static PyObject *
396 _codecs_Codecs_escape_encode_impl(PyObject *self, PyObject *str, int group_right _1, const char *errors)
397 /*[clinic end generated code: checksum=1825e81def2fe1c52abb6db205208cef0013cfc8] */
398 { 204 {
399 Py_ssize_t size; 205 Py_ssize_t size;
400 Py_ssize_t newsize; 206 Py_ssize_t newsize;
401 PyObject *v; 207 PyObject *v;
402 208
403 size = PyBytes_GET_SIZE(str); 209 size = PyBytes_GET_SIZE(data);
404 if (size > PY_SSIZE_T_MAX / 4) { 210 if (size > PY_SSIZE_T_MAX / 4) {
405 PyErr_SetString(PyExc_OverflowError, 211 PyErr_SetString(PyExc_OverflowError,
406 "string is too large to encode"); 212 "string is too large to encode");
407 return NULL; 213 return NULL;
408 } 214 }
409 newsize = 4*size; 215 newsize = 4*size;
410 v = PyBytes_FromStringAndSize(NULL, newsize); 216 v = PyBytes_FromStringAndSize(NULL, newsize);
411 217
412 if (v == NULL) { 218 if (v == NULL) {
413 return NULL; 219 return NULL;
414 } 220 }
415 else { 221 else {
416 Py_ssize_t i; 222 Py_ssize_t i;
417 char c; 223 char c;
418 char *p = PyBytes_AS_STRING(v); 224 char *p = PyBytes_AS_STRING(v);
419 225
420 for (i = 0; i < size; i++) { 226 for (i = 0; i < size; i++) {
421 /* There's at least enough room for a hex escape */ 227 /* There's at least enough room for a hex escape */
422 assert(newsize - (p - PyBytes_AS_STRING(v)) >= 4); 228 assert(newsize - (p - PyBytes_AS_STRING(v)) >= 4);
423 c = PyBytes_AS_STRING(str)[i]; 229 c = PyBytes_AS_STRING(data)[i];
424 if (c == '\'' || c == '\\') 230 if (c == '\'' || c == '\\')
425 *p++ = '\\', *p++ = c; 231 *p++ = '\\', *p++ = c;
426 else if (c == '\t') 232 else if (c == '\t')
427 *p++ = '\\', *p++ = 't'; 233 *p++ = '\\', *p++ = 't';
428 else if (c == '\n') 234 else if (c == '\n')
429 *p++ = '\\', *p++ = 'n'; 235 *p++ = '\\', *p++ = 'n';
430 else if (c == '\r') 236 else if (c == '\r')
431 *p++ = '\\', *p++ = 'r'; 237 *p++ = '\\', *p++ = 'r';
432 else if (c < ' ' || c >= 0x7f) { 238 else if (c < ' ' || c >= 0x7f) {
433 *p++ = '\\'; 239 *p++ = '\\';
434 *p++ = 'x'; 240 *p++ = 'x';
435 *p++ = Py_hexdigits[(c & 0xf0) >> 4]; 241 *p++ = Py_hexdigits[(c & 0xf0) >> 4];
436 *p++ = Py_hexdigits[c & 0xf]; 242 *p++ = Py_hexdigits[c & 0xf];
437 } 243 }
438 else 244 else
439 *p++ = c; 245 *p++ = c;
440 } 246 }
441 *p = '\0'; 247 *p = '\0';
442 if (_PyBytes_Resize(&v, (p - PyBytes_AS_STRING(v)))) { 248 if (_PyBytes_Resize(&v, (p - PyBytes_AS_STRING(v)))) {
443 return NULL; 249 return NULL;
444 } 250 }
445 } 251 }
446 252
447 return codec_tuple(v, size); 253 return codec_tuple(v, size);
448 } 254 }
449 255
450 /* --- Decoder ------------------------------------------------------------ */ 256 /* --- Decoder ------------------------------------------------------------ */
451 /*[clinic input] 257 /*[clinic input]
452 _codecs.Codecs.unicode_internal_decode 258 _codecs.unicode_internal_decode
453 obj: object 259 obj: object
454 [ 260 errors: str(nullable=True) = NULL
455 errors: str(nullable=True) 261 /
456 ] 262 [clinic start generated code]*/
457 / 263
458 [clinic start generated code]*/ 264 static PyObject *
459 265 _codecs_unicode_internal_decode_impl(PyModuleDef *module, PyObject *obj,
460 PyDoc_STRVAR(_codecs_Codecs_unicode_internal_decode__doc__, 266 const char *errors)
461 "unicode_internal_decode(obj, [errors])"); 267 /*[clinic end generated code: output=9fe47c2cd8807d92 input=71d1d53c6ea4f0fc]*/
462 268 {
463 #define _CODECS_CODECS_UNICODE_INTERNAL_DECODE_METHODDEF \
464 {"unicode_internal_decode", (PyCFunction)_codecs_Codecs_unicode_internal_dec ode, METH_VARARGS, _codecs_Codecs_unicode_internal_decode__doc__},
465
466 static PyObject *
467 _codecs_Codecs_unicode_internal_decode_impl(PyObject *self, PyObject *obj, int g roup_right_1, const char *errors);
468
469 static PyObject *
470 _codecs_Codecs_unicode_internal_decode(PyObject *self, PyObject *args)
471 {
472 PyObject *return_value = NULL;
473 PyObject *obj;
474 int group_right_1 = 0;
475 const char *errors = NULL;
476
477 switch (PyTuple_Size(args)) {
478 case 1:
479 if (!PyArg_ParseTuple(args, "O:unicode_internal_decode", &obj))
480 return NULL;
481 break;
482 case 2:
483 if (!PyArg_ParseTuple(args, "Oz:unicode_internal_decode", &obj, &err ors))
484 return NULL;
485 group_right_1 = 1;
486 break;
487 default:
488 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.unicode_internal_de code requires 1 to 2 arguments");
489 return NULL;
490 }
491 return_value = _codecs_Codecs_unicode_internal_decode_impl(self, obj, group_ right_1, errors);
492
493 return return_value;
494 }
495
496 static PyObject *
497 _codecs_Codecs_unicode_internal_decode_impl(PyObject *self, PyObject *obj, int g roup_right_1, const char *errors)
498 /*[clinic end generated code: checksum=71ea63c2d7d1b64a688913e0305dc98487e01956] */
499 {
500 const char *data;
501 Py_ssize_t size;
502
503 if (PyUnicode_Check(obj)) { 269 if (PyUnicode_Check(obj)) {
504 if (PyUnicode_READY(obj) < 0) 270 if (PyUnicode_READY(obj) < 0)
505 return NULL; 271 return NULL;
506 Py_INCREF(obj); 272 Py_INCREF(obj);
507 return codec_tuple(obj, PyUnicode_GET_LENGTH(obj)); 273 return codec_tuple(obj, PyUnicode_GET_LENGTH(obj));
508 } 274 }
509 else { 275 else {
510 if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) 276 Py_buffer view;
277 PyObject *result;
278 if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) != 0)
511 return NULL; 279 return NULL;
512 280
513 return codec_tuple(_PyUnicode_DecodeUnicodeInternal(data, size, errors), 281 result = codec_tuple(
514 size); 282 _PyUnicode_DecodeUnicodeInternal(view.buf, view.len, errors),
515 } 283 view.len);
516 } 284 PyBuffer_Release(&view);
517 285 return result;
518 /*[clinic input] 286 }
519 _codecs.Codecs.utf_7_decode 287 }
520 pbuf: Py_buffer 288
521 [ 289 /*[clinic input]
522 errors: str(nullable=True) 290 _codecs.utf_7_decode
523 [ 291 data: Py_buffer
524 final: int = 0 292 errors: str(nullable=True) = NULL
525 ] 293 final: int(c_default="0") = False
526 ] 294 /
527 / 295 [clinic start generated code]*/
528 [clinic start generated code]*/ 296
529 297 static PyObject *
530 PyDoc_STRVAR(_codecs_Codecs_utf_7_decode__doc__, 298 _codecs_utf_7_decode_impl(PyModuleDef *module, Py_buffer *data,
531 "utf_7_decode(pbuf, [errors, [final=0]])"); 299 const char *errors, int final)
532 300 /*[clinic end generated code: output=ca945e907e72e827 input=8fd0241dcc559fe8]*/
533 #define _CODECS_CODECS_UTF_7_DECODE_METHODDEF \ 301 {
534 {"utf_7_decode", (PyCFunction)_codecs_Codecs_utf_7_decode, METH_VARARGS, _co decs_Codecs_utf_7_decode__doc__}, 302 Py_ssize_t consumed = data->len;
535 303 PyObject *decoded = PyUnicode_DecodeUTF7Stateful(data->buf, data->len,
536 static PyObject * 304 errors,
537 _codecs_Codecs_utf_7_decode_impl(PyObject *self, Py_buffer *pbuf, int group_righ t_1, const char *errors, int group_right_2, int final); 305 final ? NULL : &consumed);
538
539 static PyObject *
540 _codecs_Codecs_utf_7_decode(PyObject *self, PyObject *args)
541 {
542 PyObject *return_value = NULL;
543 Py_buffer pbuf = {NULL, NULL};
544 int group_right_1 = 0;
545 const char *errors = NULL;
546 int group_right_2 = 0;
547 int final = 0;
548
549 switch (PyTuple_Size(args)) {
550 case 1:
551 if (!PyArg_ParseTuple(args, "y*:utf_7_decode", &pbuf))
552 return NULL;
553 break;
554 case 2:
555 if (!PyArg_ParseTuple(args, "y*z:utf_7_decode", &pbuf, &errors))
556 return NULL;
557 group_right_1 = 1;
558 break;
559 case 3:
560 if (!PyArg_ParseTuple(args, "y*zi:utf_7_decode", &pbuf, &errors, &fi nal))
561 return NULL;
562 group_right_1 = 1;
563 group_right_2 = 1;
564 break;
565 default:
566 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_7_decode requir es 1 to 3 arguments");
567 return NULL;
568 }
569 return_value = _codecs_Codecs_utf_7_decode_impl(self, &pbuf, group_right_1, errors, group_right_2, final);
570
571 /* Cleanup for pbuf */
572 if (pbuf.obj)
573 PyBuffer_Release(&pbuf);
574
575 return return_value;
576 }
577
578 static PyObject *
579 _codecs_Codecs_utf_7_decode_impl(PyObject *self, Py_buffer *pbuf, int group_righ t_1, const char *errors, int group_right_2, int final)
580 /*[clinic end generated code: checksum=55ae215e968f480805f4c949963e23817a34605f] */
581 {
582 Py_ssize_t consumed = pbuf->len;
583 PyObject *decoded = NULL;
584
585 decoded = PyUnicode_DecodeUTF7Stateful(pbuf->buf, pbuf->len, errors,
586 final ? NULL : &consumed);
587 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
588 if (decoded == NULL)
589 return NULL;
590 return codec_tuple(decoded, consumed); 306 return codec_tuple(decoded, consumed);
591 } 307 }
592 308
593 /*[clinic input] 309 /*[clinic input]
594 _codecs.Codecs.utf_8_decode 310 _codecs.utf_8_decode
595 pbuf: Py_buffer 311 data: Py_buffer
596 [ 312 errors: str(nullable=True) = NULL
597 errors: str(nullable=True) 313 final: int(c_default="0") = False
598 [ 314 /
599 final: int = 0 315 [clinic start generated code]*/
600 ] 316
601 ] 317 static PyObject *
602 / 318 _codecs_utf_8_decode_impl(PyModuleDef *module, Py_buffer *data,
603 [clinic start generated code]*/ 319 const char *errors, int final)
604 320 /*[clinic end generated code: output=7309f9ff4ef5c9b6 input=709f25fbc3cd9a3e]*/
605 PyDoc_STRVAR(_codecs_Codecs_utf_8_decode__doc__, 321 {
606 "utf_8_decode(pbuf, [errors, [final=0]])"); 322 Py_ssize_t consumed = data->len;
607 323 PyObject *decoded = PyUnicode_DecodeUTF8Stateful(data->buf, data->len,
608 #define _CODECS_CODECS_UTF_8_DECODE_METHODDEF \ 324 errors,
609 {"utf_8_decode", (PyCFunction)_codecs_Codecs_utf_8_decode, METH_VARARGS, _co decs_Codecs_utf_8_decode__doc__}, 325 final ? NULL : &consumed);
610
611 static PyObject *
612 _codecs_Codecs_utf_8_decode_impl(PyObject *self, Py_buffer *pbuf, int group_righ t_1, const char *errors, int group_right_2, int final);
613
614 static PyObject *
615 _codecs_Codecs_utf_8_decode(PyObject *self, PyObject *args)
616 {
617 PyObject *return_value = NULL;
618 Py_buffer pbuf = {NULL, NULL};
619 int group_right_1 = 0;
620 const char *errors = NULL;
621 int group_right_2 = 0;
622 int final = 0;
623
624 switch (PyTuple_Size(args)) {
625 case 1:
626 if (!PyArg_ParseTuple(args, "y*:utf_8_decode", &pbuf))
627 return NULL;
628 break;
629 case 2:
630 if (!PyArg_ParseTuple(args, "y*z:utf_8_decode", &pbuf, &errors))
631 return NULL;
632 group_right_1 = 1;
633 break;
634 case 3:
635 if (!PyArg_ParseTuple(args, "y*zi:utf_8_decode", &pbuf, &errors, &fi nal))
636 return NULL;
637 group_right_1 = 1;
638 group_right_2 = 1;
639 break;
640 default:
641 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_8_decode requir es 1 to 3 arguments");
642 return NULL;
643 }
644 return_value = _codecs_Codecs_utf_8_decode_impl(self, &pbuf, group_right_1, errors, group_right_2, final);
645
646 /* Cleanup for pbuf */
647 if (pbuf.obj)
648 PyBuffer_Release(&pbuf);
649
650 return return_value;
651 }
652
653 static PyObject *
654 _codecs_Codecs_utf_8_decode_impl(PyObject *self, Py_buffer *pbuf, int group_righ t_1, const char *errors, int group_right_2, int final)
655 /*[clinic end generated code: checksum=9e9ac13c3aa2323e0038e64e161ebfbac2b7223b] */
656 {
657 Py_ssize_t consumed = pbuf->len;
658 PyObject *decoded = NULL;
659
660 decoded = PyUnicode_DecodeUTF8Stateful(pbuf->buf, pbuf->len, errors,
661 final ? NULL : &consumed);
662 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the buffe
663 if (decoded == NULL)
664 return NULL;
665 return codec_tuple(decoded, consumed); 326 return codec_tuple(decoded, consumed);
666 } 327 }
667 328
668 /*[clinic input] 329 /*[clinic input]
669 _codecs.Codecs.utf_16_decode 330 _codecs.utf_16_decode
670 pbuf: Py_buffer 331 data: Py_buffer
671 [ 332 errors: str(nullable=True) = NULL
672 errors: str(nullable=True) 333 final: int(c_default="0") = False
673 [ 334 /
674 final: int = 0 335 [clinic start generated code]*/
675 ] 336
676 ] 337 static PyObject *
677 / 338 _codecs_utf_16_decode_impl(PyModuleDef *module, Py_buffer *data,
678 [clinic start generated code]*/ 339 const char *errors, int final)
679 340 /*[clinic end generated code: output=8d2fa0507d9bef2c input=81678c8535585915]*/
680 PyDoc_STRVAR(_codecs_Codecs_utf_16_decode__doc__,
681 "utf_16_decode(pbuf, [errors, [final=0]])");
682
683 #define _CODECS_CODECS_UTF_16_DECODE_METHODDEF \
684 {"utf_16_decode", (PyCFunction)_codecs_Codecs_utf_16_decode, METH_VARARGS, _ codecs_Codecs_utf_16_decode__doc__},
685
686 static PyObject *
687 _codecs_Codecs_utf_16_decode_impl(PyObject *self, Py_buffer *pbuf, int group_rig ht_1, const char *errors, int group_right_2, int final);
688
689 static PyObject *
690 _codecs_Codecs_utf_16_decode(PyObject *self, PyObject *args)
691 {
692 PyObject *return_value = NULL;
693 Py_buffer pbuf = {NULL, NULL};
694 int group_right_1 = 0;
695 const char *errors = NULL;
696 int group_right_2 = 0;
697 int final = 0;
698
699 switch (PyTuple_Size(args)) {
700 case 1:
701 if (!PyArg_ParseTuple(args, "y*:utf_16_decode", &pbuf))
702 return NULL;
703 break;
704 case 2:
705 if (!PyArg_ParseTuple(args, "y*z:utf_16_decode", &pbuf, &errors))
706 return NULL;
707 group_right_1 = 1;
708 break;
709 case 3:
710 if (!PyArg_ParseTuple(args, "y*zi:utf_16_decode", &pbuf, &errors, &f inal))
711 return NULL;
712 group_right_1 = 1;
713 group_right_2 = 1;
714 break;
715 default:
716 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_16_decode requi res 1 to 3 arguments");
717 return NULL;
718 }
719 return_value = _codecs_Codecs_utf_16_decode_impl(self, &pbuf, group_right_1, errors, group_right_2, final);
720
721 /* Cleanup for pbuf */
722 if (pbuf.obj)
723 PyBuffer_Release(&pbuf);
724
725 return return_value;
726 }
727
728 static PyObject *
729 _codecs_Codecs_utf_16_decode_impl(PyObject *self, Py_buffer *pbuf, int group_rig ht_1, const char *errors, int group_right_2, int final)
730 /*[clinic end generated code: checksum=59e4ef2baf52a76cd8628624df8523da2f6adbff] */
731 { 341 {
732 int byteorder = 0; 342 int byteorder = 0;
733 PyObject *decoded;
734 /* This is overwritten unless final is true. */ 343 /* This is overwritten unless final is true. */
735 Py_ssize_t consumed = pbuf->len; 344 Py_ssize_t consumed = data->len;
736 345 PyObject *decoded = PyUnicode_DecodeUTF16Stateful(data->buf, data->len,
737 decoded = PyUnicode_DecodeUTF16Stateful(pbuf->buf, pbuf->len, errors, 346 errors, &byteorder,
738 &byteorder, final ? NULL : &consumed); 347 final ? NULL : &consumed);
739 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
740 if (decoded == NULL)
741 return NULL;
742 return codec_tuple(decoded, consumed); 348 return codec_tuple(decoded, consumed);
743 } 349 }
744 350
745 /*[clinic input] 351 /*[clinic input]
746 _codecs.Codecs.utf_16_le_decode 352 _codecs.utf_16_le_decode
747 pbuf: Py_buffer 353 data: Py_buffer
748 [ 354 errors: str(nullable=True) = NULL
749 errors: str(nullable=True) 355 final: int(c_default="0") = False
750 [ 356 /
751 final: int = 0 357 [clinic start generated code]*/
752 ] 358
753 ] 359 static PyObject *
754 / 360 _codecs_utf_16_le_decode_impl(PyModuleDef *module, Py_buffer *data,
755 [clinic start generated code]*/ 361 const char *errors, int final)
756 362 /*[clinic end generated code: output=4fd621515ef4ce18 input=006e53be083b6777]*/
757 PyDoc_STRVAR(_codecs_Codecs_utf_16_le_decode__doc__,
758 "utf_16_le_decode(pbuf, [errors, [final=0]])");
759
760 #define _CODECS_CODECS_UTF_16_LE_DECODE_METHODDEF \
761 {"utf_16_le_decode", (PyCFunction)_codecs_Codecs_utf_16_le_decode, METH_VARA RGS, _codecs_Codecs_utf_16_le_decode__doc__},
762
763 static PyObject *
764 _codecs_Codecs_utf_16_le_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final);
765
766 static PyObject *
767 _codecs_Codecs_utf_16_le_decode(PyObject *self, PyObject *args)
768 {
769 PyObject *return_value = NULL;
770 Py_buffer pbuf = {NULL, NULL};
771 int group_right_1 = 0;
772 const char *errors = NULL;
773 int group_right_2 = 0;
774 int final = 0;
775
776 switch (PyTuple_Size(args)) {
777 case 1:
778 if (!PyArg_ParseTuple(args, "y*:utf_16_le_decode", &pbuf))
779 return NULL;
780 break;
781 case 2:
782 if (!PyArg_ParseTuple(args, "y*z:utf_16_le_decode", &pbuf, &errors))
783 return NULL;
784 group_right_1 = 1;
785 break;
786 case 3:
787 if (!PyArg_ParseTuple(args, "y*zi:utf_16_le_decode", &pbuf, &errors, &final))
788 return NULL;
789 group_right_1 = 1;
790 group_right_2 = 1;
791 break;
792 default:
793 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_16_le_decode re quires 1 to 3 arguments");
794 return NULL;
795 }
796 return_value = _codecs_Codecs_utf_16_le_decode_impl(self, &pbuf, group_right _1, errors, group_right_2, final);
797
798 /* Cleanup for pbuf */
799 if (pbuf.obj)
800 PyBuffer_Release(&pbuf);
801
802 return return_value;
803 }
804
805 static PyObject *
806 _codecs_Codecs_utf_16_le_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final)
807 /*[clinic end generated code: checksum=47b76a3cd19f37458b16f07e087b0d6790f20104] */
808 { 363 {
809 int byteorder = -1; 364 int byteorder = -1;
810 /* This is overwritten unless final is true. */ 365 /* This is overwritten unless final is true. */
811 Py_ssize_t consumed = pbuf->len; 366 Py_ssize_t consumed = data->len;
812 PyObject *decoded = NULL; 367 PyObject *decoded = PyUnicode_DecodeUTF16Stateful(data->buf, data->len,
813 368 errors, &byteorder,
814 decoded = PyUnicode_DecodeUTF16Stateful(pbuf->buf, pbuf->len, errors, 369 final ? NULL : &consumed);
815 &byteorder, final ? NULL : &consumed);
816 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
817 if (decoded == NULL)
818 return NULL;
819 return codec_tuple(decoded, consumed); 370 return codec_tuple(decoded, consumed);
820 } 371 }
821 372
822 /*[clinic input] 373 /*[clinic input]
823 _codecs.Codecs.utf_16_be_decode 374 _codecs.utf_16_be_decode
824 pbuf: Py_buffer 375 data: Py_buffer
825 [ 376 errors: str(nullable=True) = NULL
826 errors: str(nullable=True) 377 final: int(c_default="0") = False
827 [ 378 /
828 final: int = 0 379 [clinic start generated code]*/
829 ] 380
830 ] 381 static PyObject *
831 / 382 _codecs_utf_16_be_decode_impl(PyModuleDef *module, Py_buffer *data,
832 [clinic start generated code]*/ 383 const char *errors, int final)
833 384 /*[clinic end generated code: output=792f4eacb3e1fa05 input=d9490ad0f74140f3]*/
834 PyDoc_STRVAR(_codecs_Codecs_utf_16_be_decode__doc__,
835 "utf_16_be_decode(pbuf, [errors, [final=0]])");
836
837 #define _CODECS_CODECS_UTF_16_BE_DECODE_METHODDEF \
838 {"utf_16_be_decode", (PyCFunction)_codecs_Codecs_utf_16_be_decode, METH_VARA RGS, _codecs_Codecs_utf_16_be_decode__doc__},
839
840 static PyObject *
841 _codecs_Codecs_utf_16_be_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final);
842
843 static PyObject *
844 _codecs_Codecs_utf_16_be_decode(PyObject *self, PyObject *args)
845 {
846 PyObject *return_value = NULL;
847 Py_buffer pbuf = {NULL, NULL};
848 int group_right_1 = 0;
849 const char *errors = NULL;
850 int group_right_2 = 0;
851 int final = 0;
852
853 switch (PyTuple_Size(args)) {
854 case 1:
855 if (!PyArg_ParseTuple(args, "y*:utf_16_be_decode", &pbuf))
856 return NULL;
857 break;
858 case 2:
859 if (!PyArg_ParseTuple(args, "y*z:utf_16_be_decode", &pbuf, &errors))
860 return NULL;
861 group_right_1 = 1;
862 break;
863 case 3:
864 if (!PyArg_ParseTuple(args, "y*zi:utf_16_be_decode", &pbuf, &errors, &final))
865 return NULL;
866 group_right_1 = 1;
867 group_right_2 = 1;
868 break;
869 default:
870 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_16_be_decode re quires 1 to 3 arguments");
871 return NULL;
872 }
873 return_value = _codecs_Codecs_utf_16_be_decode_impl(self, &pbuf, group_right _1, errors, group_right_2, final);
874
875 /* Cleanup for pbuf */
876 if (pbuf.obj)
877 PyBuffer_Release(&pbuf);
878
879 return return_value;
880 }
881
882 static PyObject *
883 _codecs_Codecs_utf_16_be_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final)
884 /*[clinic end generated code: checksum=90df345e0bc071a26d94e1b79ba51c90efa7e3e8] */
885 { 385 {
886 int byteorder = 1; 386 int byteorder = 1;
887 /* This is overwritten unless final is true. */ 387 /* This is overwritten unless final is true. */
888 Py_ssize_t consumed = pbuf->len; 388 Py_ssize_t consumed = data->len;
889 PyObject *decoded = NULL; 389 PyObject *decoded = PyUnicode_DecodeUTF16Stateful(data->buf, data->len,
890 390 errors, &byteorder,
891 decoded = PyUnicode_DecodeUTF16Stateful(pbuf->buf, pbuf->len, errors, 391 final ? NULL : &consumed);
892 &byteorder, final ? NULL : &consumed);
893 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
894 if (decoded == NULL)
895 return NULL;
896 return codec_tuple(decoded, consumed); 392 return codec_tuple(decoded, consumed);
897 } 393 }
898 394
899 /* This non-standard version also provides access to the byteorder 395 /* This non-standard version also provides access to the byteorder
900 parameter of the builtin UTF-16 codec. 396 parameter of the builtin UTF-16 codec.
901 397
902 It returns a tuple (unicode, bytesread, byteorder) with byteorder 398 It returns a tuple (unicode, bytesread, byteorder) with byteorder
903 being the value in effect at the end of data. 399 being the value in effect at the end of data.
904 400
905 */ 401 */
906 /*[clinic input] 402 /*[clinic input]
907 _codecs.Codecs.utf_16_ex_decode 403 _codecs.utf_16_ex_decode
908 pbuf: Py_buffer 404 data: Py_buffer
909 [ 405 errors: str(nullable=True) = NULL
910 errors: str(nullable=True)
911 [
912 byteorder: int = 0 406 byteorder: int = 0
913 [ 407 final: int(c_default="0") = False
larry 2015/04/16 23:37:04 bool?
storchaka 2015/04/17 19:34:04 Semantically this is bool, but old code (here and
larry 2015/04/22 07:17:32 The only difference between "bool" (format unit 'p
storchaka 2015/04/23 12:07:32 The downside of bool converter is that it is harde
914 final: int = 0 408 /
915 ] 409 [clinic start generated code]*/
916 ] 410
917 ] 411 static PyObject *
918 / 412 _codecs_utf_16_ex_decode_impl(PyModuleDef *module, Py_buffer *data,
919 [clinic start generated code]*/ 413 const char *errors, int byteorder, int final)
920 414 /*[clinic end generated code: output=f136a186dc2defa0 input=56a16c35944e4668]*/
921 PyDoc_STRVAR(_codecs_Codecs_utf_16_ex_decode__doc__, 415 {
922 "utf_16_ex_decode(pbuf, [errors, [byteorder=0, [final=0]]])");
923
924 #define _CODECS_CODECS_UTF_16_EX_DECODE_METHODDEF \
925 {"utf_16_ex_decode", (PyCFunction)_codecs_Codecs_utf_16_ex_decode, METH_VARA RGS, _codecs_Codecs_utf_16_ex_decode__doc__},
926
927 static PyObject *
928 _codecs_Codecs_utf_16_ex_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int byteorder, int group_right_3 , int final);
929
930 static PyObject *
931 _codecs_Codecs_utf_16_ex_decode(PyObject *self, PyObject *args)
932 {
933 PyObject *return_value = NULL;
934 Py_buffer pbuf = {NULL, NULL};
935 int group_right_1 = 0;
936 const char *errors = NULL;
937 int group_right_2 = 0;
938 int byteorder = 0;
939 int group_right_3 = 0;
940 int final = 0;
941
942 switch (PyTuple_Size(args)) {
943 case 1:
944 if (!PyArg_ParseTuple(args, "y*:utf_16_ex_decode", &pbuf))
945 return NULL;
946 break;
947 case 2:
948 if (!PyArg_ParseTuple(args, "y*z:utf_16_ex_decode", &pbuf, &errors))
949 return NULL;
950 group_right_1 = 1;
951 break;
952 case 3:
953 if (!PyArg_ParseTuple(args, "y*zi:utf_16_ex_decode", &pbuf, &errors, &byteorder))
954 return NULL;
955 group_right_1 = 1;
956 group_right_2 = 1;
957 break;
958 case 4:
959 if (!PyArg_ParseTuple(args, "y*zii:utf_16_ex_decode", &pbuf, &errors , &byteorder, &final))
960 return NULL;
961 group_right_1 = 1;
962 group_right_2 = 1;
963 group_right_3 = 1;
964 break;
965 default:
966 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_16_ex_decode re quires 1 to 4 arguments");
967 return NULL;
968 }
969 return_value = _codecs_Codecs_utf_16_ex_decode_impl(self, &pbuf, group_right _1, errors, group_right_2, byteorder, group_right_3, final);
970
971 /* Cleanup for pbuf */
972 if (pbuf.obj)
973 PyBuffer_Release(&pbuf);
974
975 return return_value;
976 }
977
978 static PyObject *
979 _codecs_Codecs_utf_16_ex_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int byteorder, int group_right_3 , int final)
980 /*[clinic end generated code: checksum=64c552405bb54fce83b025875ea578a24efc1d74] */
981 {
982 PyObject *unicode, *tuple;
983 /* This is overwritten unless final is true. */ 416 /* This is overwritten unless final is true. */
984 Py_ssize_t consumed = pbuf->len; 417 Py_ssize_t consumed = data->len;
985 418
986 unicode = PyUnicode_DecodeUTF16Stateful(pbuf->buf, pbuf->len, errors, 419 PyObject *decoded = PyUnicode_DecodeUTF16Stateful(data->buf, data->len,
987 &byteorder, final ? NULL : &consumed); 420 errors, &byteorder,
988 PyBuffer_Release(pbuf); 421 final ? NULL : &consumed);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
989 if (unicode == NULL) 422 if (decoded == NULL)
990 return NULL; 423 return NULL;
991 tuple = Py_BuildValue("Oni", unicode, consumed, byteorder); 424 return Py_BuildValue("Nni", decoded, consumed, byteorder);
992 Py_DECREF(unicode); 425 }
993 return tuple; 426
994 } 427 /*[clinic input]
995 428 _codecs.utf_32_decode
996 /*[clinic input] 429 data: Py_buffer
997 _codecs.Codecs.utf_32_decode 430 errors: str(nullable=True) = NULL
998 pbuf: Py_buffer 431 final: int(c_default="0") = False
999 [ 432 /
1000 errors: str(nullable=True) 433 [clinic start generated code]*/
1001 [ 434
1002 final: int = 0 435 static PyObject *
1003 ] 436 _codecs_utf_32_decode_impl(PyModuleDef *module, Py_buffer *data,
1004 ] 437 const char *errors, int final)
1005 / 438 /*[clinic end generated code: output=b7635e55857e8efb input=778f09d112c84716]*/
1006 [clinic start generated code]*/
1007
1008 PyDoc_STRVAR(_codecs_Codecs_utf_32_decode__doc__,
1009 "utf_32_decode(pbuf, [errors, [final=0]])");
1010
1011 #define _CODECS_CODECS_UTF_32_DECODE_METHODDEF \
1012 {"utf_32_decode", (PyCFunction)_codecs_Codecs_utf_32_decode, METH_VARARGS, _ codecs_Codecs_utf_32_decode__doc__},
1013
1014 static PyObject *
1015 _codecs_Codecs_utf_32_decode_impl(PyObject *self, Py_buffer *pbuf, int group_rig ht_1, const char *errors, int group_right_2, int final);
1016
1017 static PyObject *
1018 _codecs_Codecs_utf_32_decode(PyObject *self, PyObject *args)
1019 {
1020 PyObject *return_value = NULL;
1021 Py_buffer pbuf = {NULL, NULL};
1022 int group_right_1 = 0;
1023 const char *errors = NULL;
1024 int group_right_2 = 0;
1025 int final = 0;
1026
1027 switch (PyTuple_Size(args)) {
1028 case 1:
1029 if (!PyArg_ParseTuple(args, "y*:utf_32_decode", &pbuf))
1030 return NULL;
1031 break;
1032 case 2:
1033 if (!PyArg_ParseTuple(args, "y*z:utf_32_decode", &pbuf, &errors))
1034 return NULL;
1035 group_right_1 = 1;
1036 break;
1037 case 3:
1038 if (!PyArg_ParseTuple(args, "y*zi:utf_32_decode", &pbuf, &errors, &f inal))
1039 return NULL;
1040 group_right_1 = 1;
1041 group_right_2 = 1;
1042 break;
1043 default:
1044 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_32_decode requi res 1 to 3 arguments");
1045 return NULL;
1046 }
1047 return_value = _codecs_Codecs_utf_32_decode_impl(self, &pbuf, group_right_1, errors, group_right_2, final);
1048
1049 /* Cleanup for pbuf */
1050 if (pbuf.obj)
1051 PyBuffer_Release(&pbuf);
1052
1053 return return_value;
1054 }
1055
1056 static PyObject *
1057 _codecs_Codecs_utf_32_decode_impl(PyObject *self, Py_buffer *pbuf, int group_rig ht_1, const char *errors, int group_right_2, int final)
1058 /*[clinic end generated code: checksum=bc5da0d82ec133876b0218ba496cfb1b583fdf11] */
1059 { 439 {
1060 int byteorder = 0; 440 int byteorder = 0;
1061 /* This is overwritten unless final is true. */ 441 /* This is overwritten unless final is true. */
1062 Py_ssize_t consumed = pbuf->len; 442 Py_ssize_t consumed = data->len;
1063 PyObject *decoded; 443 PyObject *decoded = PyUnicode_DecodeUTF32Stateful(data->buf, data->len,
1064 444 errors, &byteorder,
1065 decoded = PyUnicode_DecodeUTF32Stateful(pbuf->buf, pbuf->len, errors, 445 final ? NULL : &consumed);
1066 &byteorder, final ? NULL : &consumed);
1067 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1068 if (decoded == NULL)
1069 return NULL;
1070 return codec_tuple(decoded, consumed); 446 return codec_tuple(decoded, consumed);
1071 } 447 }
1072 448
1073 /*[clinic input] 449 /*[clinic input]
1074 _codecs.Codecs.utf_32_le_decode 450 _codecs.utf_32_le_decode
1075 pbuf: Py_buffer 451 data: Py_buffer
1076 [ 452 errors: str(nullable=True) = NULL
1077 errors: str(nullable=True) 453 final: int(c_default="0") = False
1078 [ 454 /
1079 final: int = 0 455 [clinic start generated code]*/
1080 ] 456
1081 ] 457 static PyObject *
1082 / 458 _codecs_utf_32_le_decode_impl(PyModuleDef *module, Py_buffer *data,
1083 [clinic start generated code]*/ 459 const char *errors, int final)
1084 460 /*[clinic end generated code: output=a79d1787d8ddf988 input=7a398c6cadca231f]*/
1085 PyDoc_STRVAR(_codecs_Codecs_utf_32_le_decode__doc__,
1086 "utf_32_le_decode(pbuf, [errors, [final=0]])");
1087
1088 #define _CODECS_CODECS_UTF_32_LE_DECODE_METHODDEF \
1089 {"utf_32_le_decode", (PyCFunction)_codecs_Codecs_utf_32_le_decode, METH_VARA RGS, _codecs_Codecs_utf_32_le_decode__doc__},
1090
1091 static PyObject *
1092 _codecs_Codecs_utf_32_le_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final);
1093
1094 static PyObject *
1095 _codecs_Codecs_utf_32_le_decode(PyObject *self, PyObject *args)
1096 {
1097 PyObject *return_value = NULL;
1098 Py_buffer pbuf = {NULL, NULL};
1099 int group_right_1 = 0;
1100 const char *errors = NULL;
1101 int group_right_2 = 0;
1102 int final = 0;
1103
1104 switch (PyTuple_Size(args)) {
1105 case 1:
1106 if (!PyArg_ParseTuple(args, "y*:utf_32_le_decode", &pbuf))
1107 return NULL;
1108 break;
1109 case 2:
1110 if (!PyArg_ParseTuple(args, "y*z:utf_32_le_decode", &pbuf, &errors))
1111 return NULL;
1112 group_right_1 = 1;
1113 break;
1114 case 3:
1115 if (!PyArg_ParseTuple(args, "y*zi:utf_32_le_decode", &pbuf, &errors, &final))
1116 return NULL;
1117 group_right_1 = 1;
1118 group_right_2 = 1;
1119 break;
1120 default:
1121 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_32_le_decode re quires 1 to 3 arguments");
1122 return NULL;
1123 }
1124 return_value = _codecs_Codecs_utf_32_le_decode_impl(self, &pbuf, group_right _1, errors, group_right_2, final);
1125
1126 /* Cleanup for pbuf */
1127 if (pbuf.obj)
1128 PyBuffer_Release(&pbuf);
1129
1130 return return_value;
1131 }
1132
1133 static PyObject *
1134 _codecs_Codecs_utf_32_le_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final)
1135 /*[clinic end generated code: checksum=70ef9bfe9a4ddd0f05176c390e5cf73bf0c5ce50] */
1136 { 461 {
1137 int byteorder = -1; 462 int byteorder = -1;
1138 /* This is overwritten unless final is true. */ 463 /* This is overwritten unless final is true. */
1139 Py_ssize_t consumed = pbuf->len; 464 Py_ssize_t consumed = data->len;
1140 PyObject *decoded; 465 PyObject *decoded = PyUnicode_DecodeUTF32Stateful(data->buf, data->len,
1141 466 errors, &byteorder,
1142 decoded = PyUnicode_DecodeUTF32Stateful(pbuf->buf, pbuf->len, errors, 467 final ? NULL : &consumed);
1143 &byteorder, final ? NULL : &consumed);
1144 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1145 if (decoded == NULL)
1146 return NULL;
1147 return codec_tuple(decoded, consumed); 468 return codec_tuple(decoded, consumed);
1148 } 469 }
1149 470
1150 /*[clinic input] 471 /*[clinic input]
1151 _codecs.Codecs.utf_32_be_decode 472 _codecs.utf_32_be_decode
1152 pbuf: Py_buffer 473 data: Py_buffer
1153 [ 474 errors: str(nullable=True) = NULL
1154 errors: str(nullable=True) 475 final: int(c_default="0") = False
1155 [ 476 /
1156 final: int = 0 477 [clinic start generated code]*/
1157 ] 478
1158 ] 479 static PyObject *
1159 / 480 _codecs_utf_32_be_decode_impl(PyModuleDef *module, Py_buffer *data,
1160 [clinic start generated code]*/ 481 const char *errors, int final)
1161 482 /*[clinic end generated code: output=a8356b0f36779981 input=573fb3c3b8ac000d]*/
1162 PyDoc_STRVAR(_codecs_Codecs_utf_32_be_decode__doc__,
1163 "utf_32_be_decode(pbuf, [errors, [final=0]])");
1164
1165 #define _CODECS_CODECS_UTF_32_BE_DECODE_METHODDEF \
1166 {"utf_32_be_decode", (PyCFunction)_codecs_Codecs_utf_32_be_decode, METH_VARA RGS, _codecs_Codecs_utf_32_be_decode__doc__},
1167
1168 static PyObject *
1169 _codecs_Codecs_utf_32_be_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final);
1170
1171 static PyObject *
1172 _codecs_Codecs_utf_32_be_decode(PyObject *self, PyObject *args)
1173 {
1174 PyObject *return_value = NULL;
1175 Py_buffer pbuf = {NULL, NULL};
1176 int group_right_1 = 0;
1177 const char *errors = NULL;
1178 int group_right_2 = 0;
1179 int final = 0;
1180
1181 switch (PyTuple_Size(args)) {
1182 case 1:
1183 if (!PyArg_ParseTuple(args, "y*:utf_32_be_decode", &pbuf))
1184 return NULL;
1185 break;
1186 case 2:
1187 if (!PyArg_ParseTuple(args, "y*z:utf_32_be_decode", &pbuf, &errors))
1188 return NULL;
1189 group_right_1 = 1;
1190 break;
1191 case 3:
1192 if (!PyArg_ParseTuple(args, "y*zi:utf_32_be_decode", &pbuf, &errors, &final))
1193 return NULL;
1194 group_right_1 = 1;
1195 group_right_2 = 1;
1196 break;
1197 default:
1198 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_32_be_decode re quires 1 to 3 arguments");
1199 return NULL;
1200 }
1201 return_value = _codecs_Codecs_utf_32_be_decode_impl(self, &pbuf, group_right _1, errors, group_right_2, final);
1202
1203 /* Cleanup for pbuf */
1204 if (pbuf.obj)
1205 PyBuffer_Release(&pbuf);
1206
1207 return return_value;
1208 }
1209
1210 static PyObject *
1211 _codecs_Codecs_utf_32_be_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int final)
1212 /*[clinic end generated code: checksum=82192b2f2263cdc196ed6be884fc3148d811a9c6] */
1213 { 483 {
1214 int byteorder = 1; 484 int byteorder = 1;
1215 /* This is overwritten unless final is true. */ 485 /* This is overwritten unless final is true. */
1216 Py_ssize_t consumed = pbuf->len; 486 Py_ssize_t consumed = data->len;
1217 PyObject *decoded; 487 PyObject *decoded = PyUnicode_DecodeUTF32Stateful(data->buf, data->len,
1218 488 errors, &byteorder,
1219 decoded = PyUnicode_DecodeUTF32Stateful(pbuf->buf, pbuf->len, errors, 489 final ? NULL : &consumed);
1220 &byteorder, final ? NULL : &consumed);
1221 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1222 if (decoded == NULL)
1223 return NULL;
1224 return codec_tuple(decoded, consumed); 490 return codec_tuple(decoded, consumed);
1225 } 491 }
1226 492
1227 /* This non-standard version also provides access to the byteorder 493 /* This non-standard version also provides access to the byteorder
1228 parameter of the builtin UTF-32 codec. 494 parameter of the builtin UTF-32 codec.
1229 495
1230 It returns a tuple (unicode, bytesread, byteorder) with byteorder 496 It returns a tuple (unicode, bytesread, byteorder) with byteorder
1231 being the value in effect at the end of data. 497 being the value in effect at the end of data.
1232 498
1233 */ 499 */
1234 /*[clinic input] 500 /*[clinic input]
1235 _codecs.Codecs.utf_32_ex_decode 501 _codecs.utf_32_ex_decode
1236 pbuf: Py_buffer 502 data: Py_buffer
1237 [ 503 errors: str(nullable=True) = NULL
1238 errors: str(nullable=True)
1239 [
1240 byteorder: int = 0 504 byteorder: int = 0
1241 [ 505 final: int(c_default="0") = False
1242 final: int = 0 506 /
1243 ] 507 [clinic start generated code]*/
1244 ] 508
1245 ] 509 static PyObject *
1246 / 510 _codecs_utf_32_ex_decode_impl(PyModuleDef *module, Py_buffer *data,
1247 [clinic start generated code]*/ 511 const char *errors, int byteorder, int final)
1248 512 /*[clinic end generated code: output=ab8c70977c1992f5 input=56c2fd15274e69a0]*/
1249 PyDoc_STRVAR(_codecs_Codecs_utf_32_ex_decode__doc__, 513 {
1250 "utf_32_ex_decode(pbuf, [errors, [byteorder=0, [final=0]]])"); 514 Py_ssize_t consumed = data->len;
1251 515 PyObject *decoded = PyUnicode_DecodeUTF32Stateful(data->buf, data->len,
1252 #define _CODECS_CODECS_UTF_32_EX_DECODE_METHODDEF \ 516 errors, &byteorder,
1253 {"utf_32_ex_decode", (PyCFunction)_codecs_Codecs_utf_32_ex_decode, METH_VARA RGS, _codecs_Codecs_utf_32_ex_decode__doc__}, 517 final ? NULL : &consumed);
1254 518 if (decoded == NULL)
1255 static PyObject * 519 return NULL;
1256 _codecs_Codecs_utf_32_ex_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int byteorder, int group_right_3 , int final); 520 return Py_BuildValue("Nni", decoded, consumed, byteorder);
1257 521 }
1258 static PyObject * 522
1259 _codecs_Codecs_utf_32_ex_decode(PyObject *self, PyObject *args) 523 /*[clinic input]
1260 { 524 _codecs.unicode_escape_decode
1261 PyObject *return_value = NULL; 525 data: Py_buffer(types={'str', 'buffer'})
1262 Py_buffer pbuf = {NULL, NULL}; 526 errors: str(nullable=True) = NULL
1263 int group_right_1 = 0; 527 /
1264 const char *errors = NULL; 528 [clinic start generated code]*/
1265 int group_right_2 = 0; 529
1266 int byteorder = 0; 530 static PyObject *
1267 int group_right_3 = 0; 531 _codecs_unicode_escape_decode_impl(PyModuleDef *module, Py_buffer *data,
1268 int final = 0; 532 const char *errors)
1269 533 /*[clinic end generated code: output=d1aa63f2620c4999 input=80f2ff60014d65c4]*/
1270 switch (PyTuple_Size(args)) { 534 {
1271 case 1: 535 PyObject *decoded = PyUnicode_DecodeUnicodeEscape(data->buf, data->len,
1272 if (!PyArg_ParseTuple(args, "y*:utf_32_ex_decode", &pbuf)) 536 errors);
1273 return NULL; 537 return codec_tuple(decoded, data->len);
1274 break; 538 }
1275 case 2: 539
1276 if (!PyArg_ParseTuple(args, "y*z:utf_32_ex_decode", &pbuf, &errors)) 540 /*[clinic input]
1277 return NULL; 541 _codecs.raw_unicode_escape_decode
1278 group_right_1 = 1; 542 data: Py_buffer(types={'str', 'buffer'})
1279 break; 543 errors: str(nullable=True) = NULL
1280 case 3: 544 /
1281 if (!PyArg_ParseTuple(args, "y*zi:utf_32_ex_decode", &pbuf, &errors, &byteorder)) 545 [clinic start generated code]*/
1282 return NULL; 546
1283 group_right_1 = 1; 547 static PyObject *
1284 group_right_2 = 1; 548 _codecs_raw_unicode_escape_decode_impl(PyModuleDef *module, Py_buffer *data,
1285 break; 549 const char *errors)
1286 case 4: 550 /*[clinic end generated code: output=0bf96cc182d81379 input=ef77c7ab98ee2c60]*/
1287 if (!PyArg_ParseTuple(args, "y*zii:utf_32_ex_decode", &pbuf, &errors , &byteorder, &final)) 551 {
1288 return NULL; 552 PyObject *decoded = PyUnicode_DecodeRawUnicodeEscape(data->buf, data->len,
1289 group_right_1 = 1; 553 errors);
1290 group_right_2 = 1; 554 return codec_tuple(decoded, data->len);
1291 group_right_3 = 1; 555 }
1292 break; 556
1293 default: 557 /*[clinic input]
1294 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_32_ex_decode re quires 1 to 4 arguments"); 558 _codecs.latin_1_decode
1295 return NULL; 559 data: Py_buffer
1296 } 560 errors: str(nullable=True) = NULL
1297 return_value = _codecs_Codecs_utf_32_ex_decode_impl(self, &pbuf, group_right _1, errors, group_right_2, byteorder, group_right_3, final); 561 /
1298 562 [clinic start generated code]*/
1299 /* Cleanup for pbuf */ 563
1300 if (pbuf.obj) 564 static PyObject *
1301 PyBuffer_Release(&pbuf); 565 _codecs_latin_1_decode_impl(PyModuleDef *module, Py_buffer *data,
1302 566 const char *errors)
1303 return return_value; 567 /*[clinic end generated code: output=66b916f5055aaf13 input=2ad8439a94444119]*/
1304 } 568 {
1305 569 PyObject *decoded = PyUnicode_DecodeLatin1(data->buf, data->len, errors);
1306 static PyObject * 570 return codec_tuple(decoded, data->len);
1307 _codecs_Codecs_utf_32_ex_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ right_1, const char *errors, int group_right_2, int byteorder, int group_right_3 , int final) 571 }
1308 /*[clinic end generated code: checksum=693fca9c1b64c1cf6111feb86c0c0eb31b934857] */ 572
1309 { 573 /*[clinic input]
1310 PyObject *unicode, *tuple; 574 _codecs.ascii_decode
1311 Py_ssize_t consumed = pbuf->len; 575 data: Py_buffer
1312 576 errors: str(nullable=True) = NULL
1313 unicode = PyUnicode_DecodeUTF32Stateful(pbuf->buf, pbuf->len, errors, 577 /
1314 &byteorder, final ? NULL : &consumed); 578 [clinic start generated code]*/
1315 PyBuffer_Release(pbuf); 579
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1316 if (unicode == NULL) 580 static PyObject *
1317 return NULL; 581 _codecs_ascii_decode_impl(PyModuleDef *module, Py_buffer *data,
1318 tuple = Py_BuildValue("Oni", unicode, consumed, byteorder); 582 const char *errors)
1319 Py_DECREF(unicode); 583 /*[clinic end generated code: output=7f213a1b5cdafc65 input=0bfd2dd60e3e0152]*/
1320 return tuple; 584 {
1321 } 585 PyObject *decoded = PyUnicode_DecodeASCII(data->buf, data->len, errors);
1322 586 return codec_tuple(decoded, data->len);
1323 /*[clinic input] 587 }
1324 _codecs.Codecs.unicode_escape_decode 588
1325 pbuf: Py_buffer(types='str bytes bytearray buffer') 589 /*[clinic input]
1326 [ 590 _codecs.charmap_decode
1327 errors: str(nullable=True) 591 data: Py_buffer
1328 ] 592 errors: str(nullable=True) = NULL
1329 / 593 mapping: object = NULL
1330 [clinic start generated code]*/ 594 /
1331 595 [clinic start generated code]*/
1332 PyDoc_STRVAR(_codecs_Codecs_unicode_escape_decode__doc__, 596
1333 "unicode_escape_decode(pbuf, [errors])"); 597 static PyObject *
1334 598 _codecs_charmap_decode_impl(PyModuleDef *module, Py_buffer *data,
1335 #define _CODECS_CODECS_UNICODE_ESCAPE_DECODE_METHODDEF \ 599 const char *errors, PyObject *mapping)
1336 {"unicode_escape_decode", (PyCFunction)_codecs_Codecs_unicode_escape_decode, METH_VARARGS, _codecs_Codecs_unicode_escape_decode__doc__}, 600 /*[clinic end generated code: output=87d27f365098bbae input=bf5ab0388adeac8e]*/
1337 601 {
1338 static PyObject * 602 PyObject *decoded;
1339 _codecs_Codecs_unicode_escape_decode_impl(PyObject *self, Py_buffer *pbuf, int g roup_right_1, const char *errors);
1340
1341 static PyObject *
1342 _codecs_Codecs_unicode_escape_decode(PyObject *self, PyObject *args)
1343 {
1344 PyObject *return_value = NULL;
1345 Py_buffer pbuf = {NULL, NULL};
1346 int group_right_1 = 0;
1347 const char *errors = NULL;
1348
1349 switch (PyTuple_Size(args)) {
1350 case 1:
1351 if (!PyArg_ParseTuple(args, "s*:unicode_escape_decode", &pbuf))
1352 return NULL;
1353 break;
1354 case 2:
1355 if (!PyArg_ParseTuple(args, "s*z:unicode_escape_decode", &pbuf, &err ors))
1356 return NULL;
1357 group_right_1 = 1;
1358 break;
1359 default:
1360 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.unicode_escape_deco de requires 1 to 2 arguments");
1361 return NULL;
1362 }
1363 return_value = _codecs_Codecs_unicode_escape_decode_impl(self, &pbuf, group_ right_1, errors);
1364
1365 /* Cleanup for pbuf */
1366 if (pbuf.obj)
1367 PyBuffer_Release(&pbuf);
1368
1369 return return_value;
1370 }
1371
1372 static PyObject *
1373 _codecs_Codecs_unicode_escape_decode_impl(PyObject *self, Py_buffer *pbuf, int g roup_right_1, const char *errors)
1374 /*[clinic end generated code: checksum=b77ca0eed0c140f6e422c8b10f1a8ecf20cd9746] */
1375 {
1376 PyObject *unicode;
1377
1378 unicode = PyUnicode_DecodeUnicodeEscape(pbuf->buf, pbuf->len, errors);
1379 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1380 return codec_tuple(unicode, pbuf->len);
1381 }
1382
1383 /*[clinic input]
1384 _codecs.Codecs.raw_unicode_escape_decode
1385 pbuf: Py_buffer(types='str bytes bytearray buffer')
1386 [
1387 errors: str(nullable=True)
1388 ]
1389 /
1390 [clinic start generated code]*/
1391
1392 PyDoc_STRVAR(_codecs_Codecs_raw_unicode_escape_decode__doc__,
1393 "raw_unicode_escape_decode(pbuf, [errors])");
1394
1395 #define _CODECS_CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF \
1396 {"raw_unicode_escape_decode", (PyCFunction)_codecs_Codecs_raw_unicode_escape _decode, METH_VARARGS, _codecs_Codecs_raw_unicode_escape_decode__doc__},
1397
1398 static PyObject *
1399 _codecs_Codecs_raw_unicode_escape_decode_impl(PyObject *self, Py_buffer *pbuf, i nt group_right_1, const char *errors);
1400
1401 static PyObject *
1402 _codecs_Codecs_raw_unicode_escape_decode(PyObject *self, PyObject *args)
1403 {
1404 PyObject *return_value = NULL;
1405 Py_buffer pbuf = {NULL, NULL};
1406 int group_right_1 = 0;
1407 const char *errors = NULL;
1408
1409 switch (PyTuple_Size(args)) {
1410 case 1:
1411 if (!PyArg_ParseTuple(args, "s*:raw_unicode_escape_decode", &pbuf))
1412 return NULL;
1413 break;
1414 case 2:
1415 if (!PyArg_ParseTuple(args, "s*z:raw_unicode_escape_decode", &pbuf, &errors))
1416 return NULL;
1417 group_right_1 = 1;
1418 break;
1419 default:
1420 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.raw_unicode_escape_ decode requires 1 to 2 arguments");
1421 return NULL;
1422 }
1423 return_value = _codecs_Codecs_raw_unicode_escape_decode_impl(self, &pbuf, gr oup_right_1, errors);
1424
1425 /* Cleanup for pbuf */
1426 if (pbuf.obj)
1427 PyBuffer_Release(&pbuf);
1428
1429 return return_value;
1430 }
1431
1432 static PyObject *
1433 _codecs_Codecs_raw_unicode_escape_decode_impl(PyObject *self, Py_buffer *pbuf, i nt group_right_1, const char *errors)
1434 /*[clinic end generated code: checksum=4d9f594d2a64f0f5a90d5fb6dd4837f07d1e4060] */
1435 {
1436 PyObject *unicode;
1437
1438 unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf->buf, pbuf->len, errors);
1439 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1440 return codec_tuple(unicode, pbuf->len);
1441 }
1442
1443 /*[clinic input]
1444 _codecs.Codecs.latin_1_decode
1445 pbuf: Py_buffer
1446 [
1447 errors: str(nullable=True)
1448 ]
1449 /
1450 [clinic start generated code]*/
1451
1452 PyDoc_STRVAR(_codecs_Codecs_latin_1_decode__doc__,
1453 "latin_1_decode(pbuf, [errors])");
1454
1455 #define _CODECS_CODECS_LATIN_1_DECODE_METHODDEF \
1456 {"latin_1_decode", (PyCFunction)_codecs_Codecs_latin_1_decode, METH_VARARGS, _codecs_Codecs_latin_1_decode__doc__},
1457
1458 static PyObject *
1459 _codecs_Codecs_latin_1_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ri ght_1, const char *errors);
1460
1461 static PyObject *
1462 _codecs_Codecs_latin_1_decode(PyObject *self, PyObject *args)
1463 {
1464 PyObject *return_value = NULL;
1465 Py_buffer pbuf = {NULL, NULL};
1466 int group_right_1 = 0;
1467 const char *errors = NULL;
1468
1469 switch (PyTuple_Size(args)) {
1470 case 1:
1471 if (!PyArg_ParseTuple(args, "y*:latin_1_decode", &pbuf))
1472 return NULL;
1473 break;
1474 case 2:
1475 if (!PyArg_ParseTuple(args, "y*z:latin_1_decode", &pbuf, &errors))
1476 return NULL;
1477 group_right_1 = 1;
1478 break;
1479 default:
1480 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.latin_1_decode requ ires 1 to 2 arguments");
1481 return NULL;
1482 }
1483 return_value = _codecs_Codecs_latin_1_decode_impl(self, &pbuf, group_right_1 , errors);
1484
1485 /* Cleanup for pbuf */
1486 if (pbuf.obj)
1487 PyBuffer_Release(&pbuf);
1488
1489 return return_value;
1490 }
1491
1492 static PyObject *
1493 _codecs_Codecs_latin_1_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ri ght_1, const char *errors)
1494 /*[clinic end generated code: checksum=468bf8d720098557e9e04922296809a672f3c21c] */
1495 {
1496 PyObject *unicode;
1497
1498 unicode = PyUnicode_DecodeLatin1(pbuf->buf, pbuf->len, errors);
1499 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1500 return codec_tuple(unicode, pbuf->len);
1501 }
1502
1503 /*[clinic input]
1504 _codecs.Codecs.ascii_decode
1505 pbuf: Py_buffer
1506 [
1507 errors: str(nullable=True)
1508 ]
1509 /
1510 [clinic start generated code]*/
1511
1512 PyDoc_STRVAR(_codecs_Codecs_ascii_decode__doc__,
1513 "ascii_decode(pbuf, [errors])");
1514
1515 #define _CODECS_CODECS_ASCII_DECODE_METHODDEF \
1516 {"ascii_decode", (PyCFunction)_codecs_Codecs_ascii_decode, METH_VARARGS, _co decs_Codecs_ascii_decode__doc__},
1517
1518 static PyObject *
1519 _codecs_Codecs_ascii_decode_impl(PyObject *self, Py_buffer *pbuf, int group_righ t_1, const char *errors);
1520
1521 static PyObject *
1522 _codecs_Codecs_ascii_decode(PyObject *self, PyObject *args)
1523 {
1524 PyObject *return_value = NULL;
1525 Py_buffer pbuf = {NULL, NULL};
1526 int group_right_1 = 0;
1527 const char *errors = NULL;
1528
1529 switch (PyTuple_Size(args)) {
1530 case 1:
1531 if (!PyArg_ParseTuple(args, "y*:ascii_decode", &pbuf))
1532 return NULL;
1533 break;
1534 case 2:
1535 if (!PyArg_ParseTuple(args, "y*z:ascii_decode", &pbuf, &errors))
1536 return NULL;
1537 group_right_1 = 1;
1538 break;
1539 default:
1540 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.ascii_decode requir es 1 to 2 arguments");
1541 return NULL;
1542 }
1543 return_value = _codecs_Codecs_ascii_decode_impl(self, &pbuf, group_right_1, errors);
1544
1545 /* Cleanup for pbuf */
1546 if (pbuf.obj)
1547 PyBuffer_Release(&pbuf);
1548
1549 return return_value;
1550 }
1551
1552 static PyObject *
1553 _codecs_Codecs_ascii_decode_impl(PyObject *self, Py_buffer *pbuf, int group_righ t_1, const char *errors)
1554 /*[clinic end generated code: checksum=71aea27a479823c89b959bd37c6f68e624baf4eb] */
1555 {
1556 PyObject *unicode;
1557
1558 unicode = PyUnicode_DecodeASCII(pbuf->buf, pbuf->len, errors);
1559 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1560 return codec_tuple(unicode, pbuf->len);
1561 }
1562
1563 /*[clinic input]
1564 _codecs.Codecs.charmap_decode
1565 pbuf: Py_buffer
1566 [
1567 errors: str(nullable=True)
1568 [
1569 mapping: object = None
1570 ]
1571 ]
1572 /
1573 [clinic start generated code]*/
1574
1575 PyDoc_STRVAR(_codecs_Codecs_charmap_decode__doc__,
1576 "charmap_decode(pbuf, [errors, [mapping=None]])");
1577
1578 #define _CODECS_CODECS_CHARMAP_DECODE_METHODDEF \
1579 {"charmap_decode", (PyCFunction)_codecs_Codecs_charmap_decode, METH_VARARGS, _codecs_Codecs_charmap_decode__doc__},
1580
1581 static PyObject *
1582 _codecs_Codecs_charmap_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ri ght_1, const char *errors, int group_right_2, PyObject *mapping);
1583
1584 static PyObject *
1585 _codecs_Codecs_charmap_decode(PyObject *self, PyObject *args)
1586 {
1587 PyObject *return_value = NULL;
1588 Py_buffer pbuf = {NULL, NULL};
1589 int group_right_1 = 0;
1590 const char *errors = NULL;
1591 int group_right_2 = 0;
1592 PyObject *mapping = Py_None;
1593
1594 switch (PyTuple_Size(args)) {
1595 case 1:
1596 if (!PyArg_ParseTuple(args, "y*:charmap_decode", &pbuf))
1597 return NULL;
1598 break;
1599 case 2:
1600 if (!PyArg_ParseTuple(args, "y*z:charmap_decode", &pbuf, &errors))
1601 return NULL;
1602 group_right_1 = 1;
1603 break;
1604 case 3:
1605 if (!PyArg_ParseTuple(args, "y*zO:charmap_decode", &pbuf, &errors, & mapping))
1606 return NULL;
1607 group_right_1 = 1;
1608 group_right_2 = 1;
1609 break;
1610 default:
1611 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.charmap_decode requ ires 1 to 3 arguments");
1612 return NULL;
1613 }
1614 return_value = _codecs_Codecs_charmap_decode_impl(self, &pbuf, group_right_1 , errors, group_right_2, mapping);
1615
1616 /* Cleanup for pbuf */
1617 if (pbuf.obj)
1618 PyBuffer_Release(&pbuf);
1619
1620 return return_value;
1621 }
1622
1623 static PyObject *
1624 _codecs_Codecs_charmap_decode_impl(PyObject *self, Py_buffer *pbuf, int group_ri ght_1, const char *errors, int group_right_2, PyObject *mapping)
1625 /*[clinic end generated code: checksum=34aa3f6eaa0943384294a8c1948c9a7bba26663c] */
1626 {
1627 PyObject *unicode;
1628 603
1629 if (mapping == Py_None) 604 if (mapping == Py_None)
1630 mapping = NULL; 605 mapping = NULL;
1631 606
1632 unicode = PyUnicode_DecodeCharmap(pbuf->buf, pbuf->len, mapping, errors); 607 decoded = PyUnicode_DecodeCharmap(data->buf, data->len, mapping, errors);
1633 PyBuffer_Release(pbuf); 608 return codec_tuple(decoded, data->len);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1634 return codec_tuple(unicode, pbuf->len);
1635 } 609 }
1636 610
1637 #ifdef HAVE_MBCS 611 #ifdef HAVE_MBCS
1638 612
1639 /*[clinic input] 613 /*[clinic input]
1640 _codecs.Codecs.mbcs_decode 614 _codecs.mbcs_decode
1641 pbuf: Py_buffer 615 data: Py_buffer
1642 [ 616 errors: str(nullable=True) = NULL
1643 errors: str(nullable=True) 617 final: int(c_default="0") = False
1644 [ 618 /
1645 final: int = 0 619 [clinic start generated code]*/
1646 ] 620
1647 ] 621 static PyObject *
1648 / 622 _codecs_mbcs_decode_impl(PyModuleDef *module, Py_buffer *data,
1649 [clinic start generated code]*/ 623 const char *errors, int final)
1650 624 /*[clinic end generated code: output=0ebaf3a5b20e53fa input=48841d508b7bacee]*/
1651 PyDoc_STRVAR(_codecs_Codecs_mbcs_decode__doc__, 625 {
1652 "mbcs_decode(pbuf, [errors, [final=0]])"); 626 Py_ssize_t consumed = data->len;
1653 627 PyObject *decoded = PyUnicode_DecodeMBCSStateful(data->buf, data->len,
1654 #define _CODECS_CODECS_MBCS_DECODE_METHODDEF \ 628 errors, final ? NULL : &consumed);
1655 {"mbcs_decode", (PyCFunction)_codecs_Codecs_mbcs_decode, METH_VARARGS, _code cs_Codecs_mbcs_decode__doc__},
1656
1657 static PyObject *
1658 _codecs_Codecs_mbcs_decode_impl(PyObject *self, Py_buffer *pbuf, int group_right _1, const char *errors, int group_right_2, int final);
1659
1660 static PyObject *
1661 _codecs_Codecs_mbcs_decode(PyObject *self, PyObject *args)
1662 {
1663 PyObject *return_value = NULL;
1664 Py_buffer pbuf = {NULL, NULL};
1665 int group_right_1 = 0;
1666 const char *errors = NULL;
1667 int group_right_2 = 0;
1668 int final = 0;
1669
1670 switch (PyTuple_Size(args)) {
1671 case 1:
1672 if (!PyArg_ParseTuple(args, "y*:mbcs_decode", &pbuf))
1673 return NULL;
1674 break;
1675 case 2:
1676 if (!PyArg_ParseTuple(args, "y*z:mbcs_decode", &pbuf, &errors))
1677 return NULL;
1678 group_right_1 = 1;
1679 break;
1680 case 3:
1681 if (!PyArg_ParseTuple(args, "y*zi:mbcs_decode", &pbuf, &errors, &fin al))
1682 return NULL;
1683 group_right_1 = 1;
1684 group_right_2 = 1;
1685 break;
1686 default:
1687 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.mbcs_decode require s 1 to 3 arguments");
1688 return NULL;
1689 }
1690 return_value = _codecs_Codecs_mbcs_decode_impl(self, &pbuf, group_right_1, e rrors, group_right_2, final);
1691
1692 /* Cleanup for pbuf */
1693 if (pbuf.obj)
1694 PyBuffer_Release(&pbuf);
1695
1696 return return_value;
1697 }
1698
1699 static PyObject *
1700 _codecs_Codecs_mbcs_decode_impl(PyObject *self, Py_buffer *pbuf, int group_right _1, const char *errors, int group_right_2, int final)
1701 /*[clinic end generated code: checksum=dc2f5295b119004d628f5ebc50dd6241096b0624] */
1702 {
1703 Py_ssize_t consumed = pbuf->len;
1704 PyObject *decoded = NULL;
1705
1706 consumed = pbuf.len;
1707
1708 decoded = PyUnicode_DecodeMBCSStateful(pbuf->buf, pbuf->len, errors,
1709 final ? NULL : &consumed);
1710 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1711 if (decoded == NULL)
1712 return NULL;
1713 return codec_tuple(decoded, consumed); 629 return codec_tuple(decoded, consumed);
1714 } 630 }
1715 631
1716 /*[clinic input] 632 /*[clinic input]
1717 _codecs.Codecs.code_page_decode 633 _codecs.code_page_decode
1718 codepage: int 634 codepage: int
1719 pbuf: Py_buffer 635 data: Py_buffer
1720 [ 636 errors: str(nullable=True) = NULL
1721 errors: str(nullable=True) 637 final: int(c_default="0") = False
1722 [ 638 /
1723 final: int = 0 639 [clinic start generated code]*/
1724 ] 640
1725 ] 641 static PyObject *
1726 / 642 _codecs_code_page_decode_impl(PyModuleDef *module, int codepage,
1727 [clinic start generated code]*/ 643 Py_buffer *data, const char *errors, int final)
1728 644 /*[clinic end generated code: output=4318e3d9971e31ba input=74f589867f3429ce]*/
1729 PyDoc_STRVAR(_codecs_Codecs_code_page_decode__doc__, 645 {
1730 "code_page_decode(codepage, pbuf, [errors, [final=0]])"); 646 Py_ssize_t consumed = data->len;
1731 647 PyObject *decoded = PyUnicode_DecodeCodePageStateful(code_page,
1732 #define _CODECS_CODECS_CODE_PAGE_DECODE_METHODDEF \ 648 data->buf, data->len,
1733 {"code_page_decode", (PyCFunction)_codecs_Codecs_code_page_decode, METH_VARA RGS, _codecs_Codecs_code_page_decode__doc__}, 649 errors,
1734 650 final ? NULL : &consume d);
1735 static PyObject *
1736 _codecs_Codecs_code_page_decode_impl(PyObject *self, int codepage, Py_buffer *pb uf, int group_right_1, const char *errors, int group_right_2, int final);
1737
1738 static PyObject *
1739 _codecs_Codecs_code_page_decode(PyObject *self, PyObject *args)
1740 {
1741 PyObject *return_value = NULL;
1742 int codepage;
1743 Py_buffer pbuf = {NULL, NULL};
1744 int group_right_1 = 0;
1745 const char *errors = NULL;
1746 int group_right_2 = 0;
1747 int final = 0;
1748
1749 switch (PyTuple_Size(args)) {
1750 case 2:
1751 if (!PyArg_ParseTuple(args, "iy*:code_page_decode", &codepage, &pbuf ))
1752 return NULL;
1753 break;
1754 case 3:
1755 if (!PyArg_ParseTuple(args, "iy*z:code_page_decode", &codepage, &pbu f, &errors))
1756 return NULL;
1757 group_right_1 = 1;
1758 break;
1759 case 4:
1760 if (!PyArg_ParseTuple(args, "iy*zi:code_page_decode", &codepage, &pb uf, &errors, &final))
1761 return NULL;
1762 group_right_1 = 1;
1763 group_right_2 = 1;
1764 break;
1765 default:
1766 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.code_page_decode re quires 2 to 4 arguments");
1767 return NULL;
1768 }
1769 return_value = _codecs_Codecs_code_page_decode_impl(self, codepage, &pbuf, g roup_right_1, errors, group_right_2, final);
1770
1771 /* Cleanup for pbuf */
1772 if (pbuf.obj)
1773 PyBuffer_Release(&pbuf);
1774
1775 return return_value;
1776 }
1777
1778 static PyObject *
1779 _codecs_Codecs_code_page_decode_impl(PyObject *self, int codepage, Py_buffer *pb uf, int group_right_1, const char *errors, int group_right_2, int final)
1780 /*[clinic end generated code: checksum=3ffd032d9d767326789b7e35ac4dfa96585f9b37] */
1781 {
1782 Py_ssize_t consumed = pbuf->len;
1783 PyObject *decoded = NULL;
1784
1785 decoded = PyUnicode_DecodeCodePageStateful(code_page,
1786 pbuf->buf, pbuf->len, errors,
1787 final ? NULL : &consumed);
1788 PyBuffer_Release(pbuf);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1789 if (decoded == NULL)
1790 return NULL;
1791 return codec_tuple(decoded, consumed); 651 return codec_tuple(decoded, consumed);
1792 } 652 }
1793 653
1794 #endif /* HAVE_MBCS */ 654 #endif /* HAVE_MBCS */
1795 655
1796 /* --- Encoder ------------------------------------------------------------ */ 656 /* --- Encoder ------------------------------------------------------------ */
1797 657
1798 /*[clinic input] 658 /*[clinic input]
1799 _codecs.Codecs.readbuffer_encode 659 _codecs.readbuffer_encode
1800 pdata: Py_buffer(types='str bytes bytearray buffer') 660 data: Py_buffer(types={'str', 'buffer'})
1801 [ 661 errors: str(nullable=True) = NULL
1802 errors: str(nullable=True) 662 /
1803 ] 663 [clinic start generated code]*/
1804 / 664
1805 [clinic start generated code]*/ 665 static PyObject *
1806 666 _codecs_readbuffer_encode_impl(PyModuleDef *module, Py_buffer *data,
1807 PyDoc_STRVAR(_codecs_Codecs_readbuffer_encode__doc__, 667 const char *errors)
1808 "readbuffer_encode(pdata, [errors])"); 668 /*[clinic end generated code: output=319cc24083299859 input=fc35dc93718e670d]*/
1809 669 {
1810 #define _CODECS_CODECS_READBUFFER_ENCODE_METHODDEF \ 670 PyObject *result = PyBytes_FromStringAndSize(data->buf, data->len);
1811 {"readbuffer_encode", (PyCFunction)_codecs_Codecs_readbuffer_encode, METH_VA RARGS, _codecs_Codecs_readbuffer_encode__doc__}, 671 return codec_tuple(result, data->len);
1812 672 }
1813 static PyObject * 673
1814 _codecs_Codecs_readbuffer_encode_impl(PyObject *self, Py_buffer *pdata, int grou p_right_1, const char *errors); 674 /*[clinic input]
1815 675 _codecs.unicode_internal_encode
1816 static PyObject *
1817 _codecs_Codecs_readbuffer_encode(PyObject *self, PyObject *args)
1818 {
1819 PyObject *return_value = NULL;
1820 Py_buffer pdata = {NULL, NULL};
1821 int group_right_1 = 0;
1822 const char *errors = NULL;
1823
1824 switch (PyTuple_Size(args)) {
1825 case 1:
1826 if (!PyArg_ParseTuple(args, "s*:readbuffer_encode", &pdata))
1827 return NULL;
1828 break;
1829 case 2:
1830 if (!PyArg_ParseTuple(args, "s*z:readbuffer_encode", &pdata, &errors ))
1831 return NULL;
1832 group_right_1 = 1;
1833 break;
1834 default:
1835 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.readbuffer_encode r equires 1 to 2 arguments");
1836 return NULL;
1837 }
1838 return_value = _codecs_Codecs_readbuffer_encode_impl(self, &pdata, group_rig ht_1, errors);
1839
1840 /* Cleanup for pdata */
1841 if (pdata.obj)
1842 PyBuffer_Release(&pdata);
1843
1844 return return_value;
1845 }
1846
1847 static PyObject *
1848 _codecs_Codecs_readbuffer_encode_impl(PyObject *self, Py_buffer *pdata, int grou p_right_1, const char *errors)
1849 /*[clinic end generated code: checksum=7b0e61e4071750fd661cdb8de8f4d57ebc2c0dee] */
1850 {
1851 const char *data = pdata->buf;
1852 Py_ssize_t size = pdata->len;
1853 PyObject *result = PyBytes_FromStringAndSize(data, size);
1854
1855 PyBuffer_Release(pdata);
larry 2014/01/19 10:59:35 This is a bug. Argument Clinic releases the Py_bu
1856 return codec_tuple(result, size);
1857 }
1858
1859 /*[clinic input]
1860 _codecs.Codecs.unicode_internal_encode
1861 obj: object 676 obj: object
1862 [ 677 errors: str(nullable=True) = NULL
1863 errors: str(nullable=True) 678 /
1864 ] 679 [clinic start generated code]*/
1865 / 680
1866 [clinic start generated code]*/ 681 static PyObject *
1867 682 _codecs_unicode_internal_encode_impl(PyModuleDef *module, PyObject *obj,
1868 PyDoc_STRVAR(_codecs_Codecs_unicode_internal_encode__doc__, 683 const char *errors)
1869 "unicode_internal_encode(obj, [errors])"); 684 /*[clinic end generated code: output=be08457068ad503b input=61192dad1fce371f]*/
1870 685 {
1871 #define _CODECS_CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF \
1872 {"unicode_internal_encode", (PyCFunction)_codecs_Codecs_unicode_internal_enc ode, METH_VARARGS, _codecs_Codecs_unicode_internal_encode__doc__},
1873
1874 static PyObject *
1875 _codecs_Codecs_unicode_internal_encode_impl(PyObject *self, PyObject *obj, int g roup_right_1, const char *errors);
1876
1877 static PyObject *
1878 _codecs_Codecs_unicode_internal_encode(PyObject *self, PyObject *args)
1879 {
1880 PyObject *return_value = NULL;
1881 PyObject *obj;
1882 int group_right_1 = 0;
1883 const char *errors = NULL;
1884
1885 switch (PyTuple_Size(args)) {
1886 case 1:
1887 if (!PyArg_ParseTuple(args, "O:unicode_internal_encode", &obj))
1888 return NULL;
1889 break;
1890 case 2:
1891 if (!PyArg_ParseTuple(args, "Oz:unicode_internal_encode", &obj, &err ors))
1892 return NULL;
1893 group_right_1 = 1;
1894 break;
1895 default:
1896 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.unicode_internal_en code requires 1 to 2 arguments");
1897 return NULL;
1898 }
1899 return_value = _codecs_Codecs_unicode_internal_encode_impl(self, obj, group_ right_1, errors);
1900
1901 return return_value;
1902 }
1903
1904 static PyObject *
1905 _codecs_Codecs_unicode_internal_encode_impl(PyObject *self, PyObject *obj, int g roup_right_1, const char *errors)
1906 /*[clinic end generated code: checksum=19efdb7139fcc2ed2cc2e57d914cac27aeab43e0] */
1907 {
1908 const char *data;
1909 Py_ssize_t len, size;
1910
1911 if (PyErr_WarnEx(PyExc_DeprecationWarning, 686 if (PyErr_WarnEx(PyExc_DeprecationWarning,
1912 "unicode_internal codec has been deprecated", 687 "unicode_internal codec has been deprecated",
1913 1)) 688 1))
1914 return NULL; 689 return NULL;
1915 690
1916 if (PyUnicode_Check(obj)) { 691 if (PyUnicode_Check(obj)) {
1917 Py_UNICODE *u; 692 Py_UNICODE *u;
693 Py_ssize_t len, size;
1918 694
1919 if (PyUnicode_READY(obj) < 0) 695 if (PyUnicode_READY(obj) < 0)
1920 return NULL; 696 return NULL;
1921 697
1922 u = PyUnicode_AsUnicodeAndSize(obj, &len); 698 u = PyUnicode_AsUnicodeAndSize(obj, &len);
1923 if (u == NULL) 699 if (u == NULL)
1924 return NULL; 700 return NULL;
1925 if (len > PY_SSIZE_T_MAX / sizeof(Py_UNICODE)) 701 if ((size_t)len > (size_t)PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
1926 return PyErr_NoMemory(); 702 return PyErr_NoMemory();
1927 size = len * sizeof(Py_UNICODE); 703 size = len * sizeof(Py_UNICODE);
1928 return codec_tuple(PyBytes_FromStringAndSize((const char*)u, size), 704 return codec_tuple(PyBytes_FromStringAndSize((const char*)u, size),
1929 PyUnicode_GET_LENGTH(obj)); 705 PyUnicode_GET_LENGTH(obj));
1930 } 706 }
1931 else { 707 else {
1932 if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) 708 Py_buffer view;
709 PyObject *result;
710 if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) != 0)
1933 return NULL; 711 return NULL;
1934 return codec_tuple(PyBytes_FromStringAndSize(data, size), size); 712 result = codec_tuple(PyBytes_FromStringAndSize(view.buf, view.len),
1935 } 713 view.len);
1936 } 714 PyBuffer_Release(&view);
1937 715 return result;
1938 /*[clinic input] 716 }
1939 _codecs.Codecs.utf_7_encode 717 }
1940 str: object 718
1941 [ 719 /*[clinic input]
1942 errors: str(nullable=True) 720 _codecs.utf_7_encode
1943 ] 721 str: object
1944 / 722 errors: str(nullable=True) = NULL
1945 [clinic start generated code]*/ 723 /
1946 724 [clinic start generated code]*/
1947 PyDoc_STRVAR(_codecs_Codecs_utf_7_encode__doc__, 725
1948 "utf_7_encode(str, [errors])"); 726 static PyObject *
1949 727 _codecs_utf_7_encode_impl(PyModuleDef *module, PyObject *str,
1950 #define _CODECS_CODECS_UTF_7_ENCODE_METHODDEF \ 728 const char *errors)
1951 {"utf_7_encode", (PyCFunction)_codecs_Codecs_utf_7_encode, METH_VARARGS, _co decs_Codecs_utf_7_encode__doc__}, 729 /*[clinic end generated code: output=a7accc496a32b759 input=802ba3f495219bbc]*/
1952
1953 static PyObject *
1954 _codecs_Codecs_utf_7_encode_impl(PyObject *self, PyObject *str, int group_right_ 1, const char *errors);
1955
1956 static PyObject *
1957 _codecs_Codecs_utf_7_encode(PyObject *self, PyObject *args)
1958 {
1959 PyObject *return_value = NULL;
1960 PyObject *str;
1961 int group_right_1 = 0;
1962 const char *errors = NULL;
1963
1964 switch (PyTuple_Size(args)) {
1965 case 1:
1966 if (!PyArg_ParseTuple(args, "O:utf_7_encode", &str))
1967 return NULL;
1968 break;
1969 case 2:
1970 if (!PyArg_ParseTuple(args, "Oz:utf_7_encode", &str, &errors))
1971 return NULL;
1972 group_right_1 = 1;
1973 break;
1974 default:
1975 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_7_encode requir es 1 to 2 arguments");
1976 return NULL;
1977 }
1978 return_value = _codecs_Codecs_utf_7_encode_impl(self, str, group_right_1, er rors);
1979
1980 return return_value;
1981 }
1982
1983 static PyObject *
1984 _codecs_Codecs_utf_7_encode_impl(PyObject *self, PyObject *str, int group_right_ 1, const char *errors)
1985 /*[clinic end generated code: checksum=e8806f9456a8449b514fbd097067cff45008d28a] */
1986 { 730 {
1987 PyObject *v; 731 PyObject *v;
1988 732
1989 str = PyUnicode_FromObject(str); 733 str = PyUnicode_FromObject(str);
1990 if (str == NULL || PyUnicode_READY(str) < 0) { 734 if (str == NULL || PyUnicode_READY(str) < 0) {
1991 Py_XDECREF(str); 735 Py_XDECREF(str);
1992 return NULL; 736 return NULL;
1993 } 737 }
1994 v = codec_tuple(_PyUnicode_EncodeUTF7(str, 0, 0, errors), 738 v = codec_tuple(_PyUnicode_EncodeUTF7(str, 0, 0, errors),
1995 PyUnicode_GET_LENGTH(str)); 739 PyUnicode_GET_LENGTH(str));
1996 Py_DECREF(str); 740 Py_DECREF(str);
1997 return v; 741 return v;
1998 } 742 }
1999 743
2000 /*[clinic input] 744 /*[clinic input]
2001 _codecs.Codecs.utf_8_encode 745 _codecs.utf_8_encode
2002 str: object 746 str: object
2003 [ 747 errors: str(nullable=True) = NULL
2004 errors: str(nullable=True) 748 /
2005 ] 749 [clinic start generated code]*/
2006 / 750
2007 [clinic start generated code]*/ 751 static PyObject *
2008 752 _codecs_utf_8_encode_impl(PyModuleDef *module, PyObject *str,
2009 PyDoc_STRVAR(_codecs_Codecs_utf_8_encode__doc__, 753 const char *errors)
2010 "utf_8_encode(str, [errors])"); 754 /*[clinic end generated code: output=ec831d80e7aedede input=5c283859a2a90bf7]*/
2011
2012 #define _CODECS_CODECS_UTF_8_ENCODE_METHODDEF \
2013 {"utf_8_encode", (PyCFunction)_codecs_Codecs_utf_8_encode, METH_VARARGS, _co decs_Codecs_utf_8_encode__doc__},
2014
2015 static PyObject *
2016 _codecs_Codecs_utf_8_encode_impl(PyObject *self, PyObject *str, int group_right_ 1, const char *errors);
2017
2018 static PyObject *
2019 _codecs_Codecs_utf_8_encode(PyObject *self, PyObject *args)
2020 {
2021 PyObject *return_value = NULL;
2022 PyObject *str;
2023 int group_right_1 = 0;
2024 const char *errors = NULL;
2025
2026 switch (PyTuple_Size(args)) {
2027 case 1:
2028 if (!PyArg_ParseTuple(args, "O:utf_8_encode", &str))
2029 return NULL;
2030 break;
2031 case 2:
2032 if (!PyArg_ParseTuple(args, "Oz:utf_8_encode", &str, &errors))
2033 return NULL;
2034 group_right_1 = 1;
2035 break;
2036 default:
2037 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_8_encode requir es 1 to 2 arguments");
2038 return NULL;
2039 }
2040 return_value = _codecs_Codecs_utf_8_encode_impl(self, str, group_right_1, er rors);
2041
2042 return return_value;
2043 }
2044
2045 static PyObject *
2046 _codecs_Codecs_utf_8_encode_impl(PyObject *self, PyObject *str, int group_right_ 1, const char *errors)
2047 /*[clinic end generated code: checksum=0166a55bda0daf434ec7c29afcf8057820e3e930] */
2048 { 755 {
2049 PyObject *v; 756 PyObject *v;
2050 757
2051 str = PyUnicode_FromObject(str); 758 str = PyUnicode_FromObject(str);
2052 if (str == NULL || PyUnicode_READY(str) < 0) { 759 if (str == NULL || PyUnicode_READY(str) < 0) {
2053 Py_XDECREF(str); 760 Py_XDECREF(str);
2054 return NULL; 761 return NULL;
2055 } 762 }
2056 v = codec_tuple(PyUnicode_AsEncodedString(str, "utf-8", errors), 763 v = codec_tuple(PyUnicode_AsEncodedString(str, "utf-8", errors),
2057 PyUnicode_GET_LENGTH(str)); 764 PyUnicode_GET_LENGTH(str));
2058 Py_DECREF(str); 765 Py_DECREF(str);
2059 return v; 766 return v;
2060 } 767 }
2061 768
2062 /* This version provides access to the byteorder parameter of the 769 /* This version provides access to the byteorder parameter of the
2063 builtin UTF-16 codecs as optional third argument. It defaults to 0 770 builtin UTF-16 codecs as optional third argument. It defaults to 0
2064 which means: use the native byte order and prepend the data with a 771 which means: use the native byte order and prepend the data with a
2065 BOM mark. 772 BOM mark.
2066 773
2067 */ 774 */
2068 775
2069 /*[clinic input] 776 /*[clinic input]
2070 _codecs.Codecs.utf_16_encode 777 _codecs.utf_16_encode
2071 str: object 778 str: object
2072 [ 779 errors: str(nullable=True) = NULL
2073 errors: str(nullable=True)
2074 [
2075 byteorder: int = 0 780 byteorder: int = 0
2076 ] 781 /
2077 ] 782 [clinic start generated code]*/
2078 / 783
2079 [clinic start generated code]*/ 784 static PyObject *
2080 785 _codecs_utf_16_encode_impl(PyModuleDef *module, PyObject *str,
2081 PyDoc_STRVAR(_codecs_Codecs_utf_16_encode__doc__, 786 const char *errors, int byteorder)
2082 "utf_16_encode(str, [errors, [byteorder=0]])"); 787 /*[clinic end generated code: output=93ac58e960a9ee4d input=ed850025591019db]*/
2083
2084 #define _CODECS_CODECS_UTF_16_ENCODE_METHODDEF \
2085 {"utf_16_encode", (PyCFunction)_codecs_Codecs_utf_16_encode, METH_VARARGS, _ codecs_Codecs_utf_16_encode__doc__},
2086
2087 static PyObject *
2088 _codecs_Codecs_utf_16_encode_impl(PyObject *self, PyObject *str, int group_right _1, const char *errors, int group_right_2, int byteorder);
2089
2090 static PyObject *
2091 _codecs_Codecs_utf_16_encode(PyObject *self, PyObject *args)
2092 {
2093 PyObject *return_value = NULL;
2094 PyObject *str;
2095 int group_right_1 = 0;
2096 const char *errors = NULL;
2097 int group_right_2 = 0;
2098 int byteorder = 0;
2099
2100 switch (PyTuple_Size(args)) {
2101 case 1:
2102 if (!PyArg_ParseTuple(args, "O:utf_16_encode", &str))
2103 return NULL;
2104 break;
2105 case 2:
2106 if (!PyArg_ParseTuple(args, "Oz:utf_16_encode", &str, &errors))
2107 return NULL;
2108 group_right_1 = 1;
2109 break;
2110 case 3:
2111 if (!PyArg_ParseTuple(args, "Ozi:utf_16_encode", &str, &errors, &byt eorder))
2112 return NULL;
2113 group_right_1 = 1;
2114 group_right_2 = 1;
2115 break;
2116 default:
2117 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_16_encode requi res 1 to 3 arguments");
2118 return NULL;
2119 }
2120 return_value = _codecs_Codecs_utf_16_encode_impl(self, str, group_right_1, e rrors, group_right_2, byteorder);
2121
2122 return return_value;
2123 }
2124
2125 static PyObject *
2126 _codecs_Codecs_utf_16_encode_impl(PyObject *self, PyObject *str, int group_right _1, const char *errors, int group_right_2, int byteorder)
2127 /*[clinic end generated code: checksum=6dfd84bbe81e21021754ec75a9e45eaf1fcf54bf] */
2128 { 788 {
2129 PyObject *v; 789 PyObject *v;
2130 790
2131 str = PyUnicode_FromObject(str); 791 str = PyUnicode_FromObject(str);
2132 if (str == NULL || PyUnicode_READY(str) < 0) { 792 if (str == NULL || PyUnicode_READY(str) < 0) {
2133 Py_XDECREF(str); 793 Py_XDECREF(str);
2134 return NULL; 794 return NULL;
2135 } 795 }
2136 v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, byteorder), 796 v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, byteorder),
2137 PyUnicode_GET_LENGTH(str)); 797 PyUnicode_GET_LENGTH(str));
2138 Py_DECREF(str); 798 Py_DECREF(str);
2139 return v; 799 return v;
2140 } 800 }
2141 801
2142 /*[clinic input] 802 /*[clinic input]
2143 _codecs.Codecs.utf_16_le_encode 803 _codecs.utf_16_le_encode
2144 str: object 804 str: object
2145 [ 805 errors: str(nullable=True) = NULL
2146 errors: str(nullable=True) 806 /
2147 ] 807 [clinic start generated code]*/
2148 / 808
2149 [clinic start generated code]*/ 809 static PyObject *
2150 810 _codecs_utf_16_le_encode_impl(PyModuleDef *module, PyObject *str,
2151 PyDoc_STRVAR(_codecs_Codecs_utf_16_le_encode__doc__, 811 const char *errors)
2152 "utf_16_le_encode(str, [errors])"); 812 /*[clinic end generated code: output=422bedb8da34fb66 input=950fcf919f117cb7]*/
2153
2154 #define _CODECS_CODECS_UTF_16_LE_ENCODE_METHODDEF \
2155 {"utf_16_le_encode", (PyCFunction)_codecs_Codecs_utf_16_le_encode, METH_VARA RGS, _codecs_Codecs_utf_16_le_encode__doc__},
2156
2157 static PyObject *
2158 _codecs_Codecs_utf_16_le_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors);
2159
2160 static PyObject *
2161 _codecs_Codecs_utf_16_le_encode(PyObject *self, PyObject *args)
2162 {
2163 PyObject *return_value = NULL;
2164 PyObject *str;
2165 int group_right_1 = 0;
2166 const char *errors = NULL;
2167
2168 switch (PyTuple_Size(args)) {
2169 case 1:
2170 if (!PyArg_ParseTuple(args, "O:utf_16_le_encode", &str))
2171 return NULL;
2172 break;
2173 case 2:
2174 if (!PyArg_ParseTuple(args, "Oz:utf_16_le_encode", &str, &errors))
2175 return NULL;
2176 group_right_1 = 1;
2177 break;
2178 default:
2179 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_16_le_encode re quires 1 to 2 arguments");
2180 return NULL;
2181 }
2182 return_value = _codecs_Codecs_utf_16_le_encode_impl(self, str, group_right_1 , errors);
2183
2184 return return_value;
2185 }
2186
2187 static PyObject *
2188 _codecs_Codecs_utf_16_le_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors)
2189 /*[clinic end generated code: checksum=d1df6209b7e67b93eb87076368ace9155a58c28e] */
2190 { 813 {
2191 PyObject *v; 814 PyObject *v;
2192 815
2193 str = PyUnicode_FromObject(str); 816 str = PyUnicode_FromObject(str);
2194 if (str == NULL || PyUnicode_READY(str) < 0) { 817 if (str == NULL || PyUnicode_READY(str) < 0) {
2195 Py_XDECREF(str); 818 Py_XDECREF(str);
2196 return NULL; 819 return NULL;
2197 } 820 }
2198 v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, -1), 821 v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, -1),
2199 PyUnicode_GET_LENGTH(str)); 822 PyUnicode_GET_LENGTH(str));
2200 Py_DECREF(str); 823 Py_DECREF(str);
2201 return v; 824 return v;
2202 } 825 }
2203 826
2204 /*[clinic input] 827 /*[clinic input]
2205 _codecs.Codecs.utf_16_be_encode 828 _codecs.utf_16_be_encode
2206 str: object 829 str: object
2207 [ 830 errors: str(nullable=True) = NULL
2208 errors: str(nullable=True) 831 /
2209 ] 832 [clinic start generated code]*/
2210 / 833
2211 [clinic start generated code]*/ 834 static PyObject *
2212 835 _codecs_utf_16_be_encode_impl(PyModuleDef *module, PyObject *str,
2213 PyDoc_STRVAR(_codecs_Codecs_utf_16_be_encode__doc__, 836 const char *errors)
2214 "utf_16_be_encode(str, [errors])"); 837 /*[clinic end generated code: output=3aa7ee9502acdd77 input=65a55a23d2a1e18d]*/
2215
2216 #define _CODECS_CODECS_UTF_16_BE_ENCODE_METHODDEF \
2217 {"utf_16_be_encode", (PyCFunction)_codecs_Codecs_utf_16_be_encode, METH_VARA RGS, _codecs_Codecs_utf_16_be_encode__doc__},
2218
2219 static PyObject *
2220 _codecs_Codecs_utf_16_be_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors);
2221
2222 static PyObject *
2223 _codecs_Codecs_utf_16_be_encode(PyObject *self, PyObject *args)
2224 {
2225 PyObject *return_value = NULL;
2226 PyObject *str;
2227 int group_right_1 = 0;
2228 const char *errors = NULL;
2229
2230 switch (PyTuple_Size(args)) {
2231 case 1:
2232 if (!PyArg_ParseTuple(args, "O:utf_16_be_encode", &str))
2233 return NULL;
2234 break;
2235 case 2:
2236 if (!PyArg_ParseTuple(args, "Oz:utf_16_be_encode", &str, &errors))
2237 return NULL;
2238 group_right_1 = 1;
2239 break;
2240 default:
2241 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_16_be_encode re quires 1 to 2 arguments");
2242 return NULL;
2243 }
2244 return_value = _codecs_Codecs_utf_16_be_encode_impl(self, str, group_right_1 , errors);
2245
2246 return return_value;
2247 }
2248
2249 static PyObject *
2250 _codecs_Codecs_utf_16_be_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors)
2251 /*[clinic end generated code: checksum=b999bb3a4967df4509ba0b1b0685d3b4fabeb26d] */
2252 { 838 {
2253 PyObject *v; 839 PyObject *v;
2254 840
2255 str = PyUnicode_FromObject(str); 841 str = PyUnicode_FromObject(str);
2256 if (str == NULL || PyUnicode_READY(str) < 0) { 842 if (str == NULL || PyUnicode_READY(str) < 0) {
2257 Py_XDECREF(str); 843 Py_XDECREF(str);
2258 return NULL; 844 return NULL;
2259 } 845 }
2260 v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, +1), 846 v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, +1),
2261 PyUnicode_GET_LENGTH(str)); 847 PyUnicode_GET_LENGTH(str));
2262 Py_DECREF(str); 848 Py_DECREF(str);
2263 return v; 849 return v;
2264 } 850 }
2265 851
2266 /* This version provides access to the byteorder parameter of the 852 /* This version provides access to the byteorder parameter of the
2267 builtin UTF-32 codecs as optional third argument. It defaults to 0 853 builtin UTF-32 codecs as optional third argument. It defaults to 0
2268 which means: use the native byte order and prepend the data with a 854 which means: use the native byte order and prepend the data with a
2269 BOM mark. 855 BOM mark.
2270 856
2271 */ 857 */
2272 858
2273 /*[clinic input] 859 /*[clinic input]
2274 _codecs.Codecs.utf_32_encode 860 _codecs.utf_32_encode
2275 str: object 861 str: object
2276 [ 862 errors: str(nullable=True) = NULL
2277 errors: str(nullable=True)
2278 [
2279 byteorder: int = 0 863 byteorder: int = 0
2280 ] 864 /
2281 ] 865 [clinic start generated code]*/
2282 / 866
2283 [clinic start generated code]*/ 867 static PyObject *
2284 868 _codecs_utf_32_encode_impl(PyModuleDef *module, PyObject *str,
2285 PyDoc_STRVAR(_codecs_Codecs_utf_32_encode__doc__, 869 const char *errors, int byteorder)
2286 "utf_32_encode(str, [errors, [byteorder=0]])"); 870 /*[clinic end generated code: output=3e7d5a003b02baed input=452ef1b8f0b8c3d5]*/
2287
2288 #define _CODECS_CODECS_UTF_32_ENCODE_METHODDEF \
2289 {"utf_32_encode", (PyCFunction)_codecs_Codecs_utf_32_encode, METH_VARARGS, _ codecs_Codecs_utf_32_encode__doc__},
2290
2291 static PyObject *
2292 _codecs_Codecs_utf_32_encode_impl(PyObject *self, PyObject *str, int group_right _1, const char *errors, int group_right_2, int byteorder);
2293
2294 static PyObject *
2295 _codecs_Codecs_utf_32_encode(PyObject *self, PyObject *args)
2296 {
2297 PyObject *return_value = NULL;
2298 PyObject *str;
2299 int group_right_1 = 0;
2300 const char *errors = NULL;
2301 int group_right_2 = 0;
2302 int byteorder = 0;
2303
2304 switch (PyTuple_Size(args)) {
2305 case 1:
2306 if (!PyArg_ParseTuple(args, "O:utf_32_encode", &str))
2307 return NULL;
2308 break;
2309 case 2:
2310 if (!PyArg_ParseTuple(args, "Oz:utf_32_encode", &str, &errors))
2311 return NULL;
2312 group_right_1 = 1;
2313 break;
2314 case 3:
2315 if (!PyArg_ParseTuple(args, "Ozi:utf_32_encode", &str, &errors, &byt eorder))
2316 return NULL;
2317 group_right_1 = 1;
2318 group_right_2 = 1;
2319 break;
2320 default:
2321 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_32_encode requi res 1 to 3 arguments");
2322 return NULL;
2323 }
2324 return_value = _codecs_Codecs_utf_32_encode_impl(self, str, group_right_1, e rrors, group_right_2, byteorder);
2325
2326 return return_value;
2327 }
2328
2329 static PyObject *
2330 _codecs_Codecs_utf_32_encode_impl(PyObject *self, PyObject *str, int group_right _1, const char *errors, int group_right_2, int byteorder)
2331 /*[clinic end generated code: checksum=95bce5eae0e1726ea41a3b0037c8c9d3f67aa098] */
2332 { 871 {
2333 PyObject *v; 872 PyObject *v;
2334 873
2335 str = PyUnicode_FromObject(str); 874 str = PyUnicode_FromObject(str);
2336 if (str == NULL || PyUnicode_READY(str) < 0) { 875 if (str == NULL || PyUnicode_READY(str) < 0) {
2337 Py_XDECREF(str); 876 Py_XDECREF(str);
2338 return NULL; 877 return NULL;
2339 } 878 }
2340 v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, byteorder), 879 v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, byteorder),
2341 PyUnicode_GET_LENGTH(str)); 880 PyUnicode_GET_LENGTH(str));
2342 Py_DECREF(str); 881 Py_DECREF(str);
2343 return v; 882 return v;
2344 } 883 }
2345 884
2346 /*[clinic input] 885 /*[clinic input]
2347 _codecs.Codecs.utf_32_le_encode 886 _codecs.utf_32_le_encode
2348 str: object 887 str: object
2349 [ 888 errors: str(nullable=True) = NULL
2350 errors: str(nullable=True) 889 /
2351 ] 890 [clinic start generated code]*/
2352 / 891
2353 [clinic start generated code]*/ 892 static PyObject *
2354 893 _codecs_utf_32_le_encode_impl(PyModuleDef *module, PyObject *str,
2355 PyDoc_STRVAR(_codecs_Codecs_utf_32_le_encode__doc__, 894 const char *errors)
2356 "utf_32_le_encode(str, [errors])"); 895 /*[clinic end generated code: output=5dda641cd33dbfc2 input=a8e2cc9b4dbf40d9]*/
2357
2358 #define _CODECS_CODECS_UTF_32_LE_ENCODE_METHODDEF \
2359 {"utf_32_le_encode", (PyCFunction)_codecs_Codecs_utf_32_le_encode, METH_VARA RGS, _codecs_Codecs_utf_32_le_encode__doc__},
2360
2361 static PyObject *
2362 _codecs_Codecs_utf_32_le_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors);
2363
2364 static PyObject *
2365 _codecs_Codecs_utf_32_le_encode(PyObject *self, PyObject *args)
2366 {
2367 PyObject *return_value = NULL;
2368 PyObject *str;
2369 int group_right_1 = 0;
2370 const char *errors = NULL;
2371
2372 switch (PyTuple_Size(args)) {
2373 case 1:
2374 if (!PyArg_ParseTuple(args, "O:utf_32_le_encode", &str))
2375 return NULL;
2376 break;
2377 case 2:
2378 if (!PyArg_ParseTuple(args, "Oz:utf_32_le_encode", &str, &errors))
2379 return NULL;
2380 group_right_1 = 1;
2381 break;
2382 default:
2383 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_32_le_encode re quires 1 to 2 arguments");
2384 return NULL;
2385 }
2386 return_value = _codecs_Codecs_utf_32_le_encode_impl(self, str, group_right_1 , errors);
2387
2388 return return_value;
2389 }
2390
2391 static PyObject *
2392 _codecs_Codecs_utf_32_le_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors)
2393 /*[clinic end generated code: checksum=211158cd66e13ddb41cf41c21232712b24a6d2c0] */
2394 { 896 {
2395 PyObject *v; 897 PyObject *v;
2396 898
2397 str = PyUnicode_FromObject(str); 899 str = PyUnicode_FromObject(str);
2398 if (str == NULL || PyUnicode_READY(str) < 0) { 900 if (str == NULL || PyUnicode_READY(str) < 0) {
2399 Py_XDECREF(str); 901 Py_XDECREF(str);
2400 return NULL; 902 return NULL;
2401 } 903 }
2402 v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, -1), 904 v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, -1),
2403 PyUnicode_GET_LENGTH(str)); 905 PyUnicode_GET_LENGTH(str));
2404 Py_DECREF(str); 906 Py_DECREF(str);
2405 return v; 907 return v;
2406 } 908 }
2407 909
2408 /*[clinic input] 910 /*[clinic input]
2409 _codecs.Codecs.utf_32_be_encode 911 _codecs.utf_32_be_encode
2410 str: object 912 str: object
2411 [ 913 errors: str(nullable=True) = NULL
2412 errors: str(nullable=True) 914 /
2413 ] 915 [clinic start generated code]*/
2414 / 916
2415 [clinic start generated code]*/ 917 static PyObject *
2416 918 _codecs_utf_32_be_encode_impl(PyModuleDef *module, PyObject *str,
2417 PyDoc_STRVAR(_codecs_Codecs_utf_32_be_encode__doc__, 919 const char *errors)
2418 "utf_32_be_encode(str, [errors])"); 920 /*[clinic end generated code: output=ccca8b44d91a7c7a input=cef51fb9de6a04b3]*/
2419
2420 #define _CODECS_CODECS_UTF_32_BE_ENCODE_METHODDEF \
2421 {"utf_32_be_encode", (PyCFunction)_codecs_Codecs_utf_32_be_encode, METH_VARA RGS, _codecs_Codecs_utf_32_be_encode__doc__},
2422
2423 static PyObject *
2424 _codecs_Codecs_utf_32_be_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors);
2425
2426 static PyObject *
2427 _codecs_Codecs_utf_32_be_encode(PyObject *self, PyObject *args)
2428 {
2429 PyObject *return_value = NULL;
2430 PyObject *str;
2431 int group_right_1 = 0;
2432 const char *errors = NULL;
2433
2434 switch (PyTuple_Size(args)) {
2435 case 1:
2436 if (!PyArg_ParseTuple(args, "O:utf_32_be_encode", &str))
2437 return NULL;
2438 break;
2439 case 2:
2440 if (!PyArg_ParseTuple(args, "Oz:utf_32_be_encode", &str, &errors))
2441 return NULL;
2442 group_right_1 = 1;
2443 break;
2444 default:
2445 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.utf_32_be_encode re quires 1 to 2 arguments");
2446 return NULL;
2447 }
2448 return_value = _codecs_Codecs_utf_32_be_encode_impl(self, str, group_right_1 , errors);
2449
2450 return return_value;
2451 }
2452
2453 static PyObject *
2454 _codecs_Codecs_utf_32_be_encode_impl(PyObject *self, PyObject *str, int group_ri ght_1, const char *errors)
2455 /*[clinic end generated code: checksum=f4f360e27584752de8f391612c0d3856ac5f631d] */
2456 { 921 {
2457 PyObject *v; 922 PyObject *v;
2458 923
2459 str = PyUnicode_FromObject(str); 924 str = PyUnicode_FromObject(str);
2460 if (str == NULL || PyUnicode_READY(str) < 0) { 925 if (str == NULL || PyUnicode_READY(str) < 0) {
2461 Py_XDECREF(str); 926 Py_XDECREF(str);
2462 return NULL; 927 return NULL;
2463 } 928 }
2464 v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, +1), 929 v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, +1),
2465 PyUnicode_GET_LENGTH(str)); 930 PyUnicode_GET_LENGTH(str));
2466 Py_DECREF(str); 931 Py_DECREF(str);
2467 return v; 932 return v;
2468 } 933 }
2469 934
2470 /*[clinic input] 935 /*[clinic input]
2471 _codecs.Codecs.unicode_escape_encode 936 _codecs.unicode_escape_encode
2472 str: object 937 str: object
2473 [ 938 errors: str(nullable=True) = NULL
2474 errors: str(nullable=True) 939 /
2475 ] 940 [clinic start generated code]*/
2476 / 941
2477 [clinic start generated code]*/ 942 static PyObject *
2478 943 _codecs_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str,
2479 PyDoc_STRVAR(_codecs_Codecs_unicode_escape_encode__doc__, 944 const char *errors)
2480 "unicode_escape_encode(str, [errors])"); 945 /*[clinic end generated code: output=389f23d2b8f8d80b input=a9b4d66329b51e5b]*/
2481
2482 #define _CODECS_CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF \
2483 {"unicode_escape_encode", (PyCFunction)_codecs_Codecs_unicode_escape_encode, METH_VARARGS, _codecs_Codecs_unicode_escape_encode__doc__},
2484
2485 static PyObject *
2486 _codecs_Codecs_unicode_escape_encode_impl(PyObject *self, PyObject *str, int gro up_right_1, const char *errors);
2487
2488 static PyObject *
2489 _codecs_Codecs_unicode_escape_encode(PyObject *self, PyObject *args)
2490 {
2491 PyObject *return_value = NULL;
2492 PyObject *str;
2493 int group_right_1 = 0;
2494 const char *errors = NULL;
2495
2496 switch (PyTuple_Size(args)) {
2497 case 1:
2498 if (!PyArg_ParseTuple(args, "O:unicode_escape_encode", &str))
2499 return NULL;
2500 break;
2501 case 2:
2502 if (!PyArg_ParseTuple(args, "Oz:unicode_escape_encode", &str, &error s))
2503 return NULL;
2504 group_right_1 = 1;
2505 break;
2506 default:
2507 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.unicode_escape_enco de requires 1 to 2 arguments");
2508 return NULL;
2509 }
2510 return_value = _codecs_Codecs_unicode_escape_encode_impl(self, str, group_ri ght_1, errors);
2511
2512 return return_value;
2513 }
2514
2515 static PyObject *
2516 _codecs_Codecs_unicode_escape_encode_impl(PyObject *self, PyObject *str, int gro up_right_1, const char *errors)
2517 /*[clinic end generated code: checksum=606f44f27f41c96420c5918de31951c425308c39] */
2518 { 946 {
2519 PyObject *v; 947 PyObject *v;
2520 948
2521 str = PyUnicode_FromObject(str); 949 str = PyUnicode_FromObject(str);
2522 if (str == NULL || PyUnicode_READY(str) < 0) { 950 if (str == NULL || PyUnicode_READY(str) < 0) {
2523 Py_XDECREF(str); 951 Py_XDECREF(str);
2524 return NULL; 952 return NULL;
2525 } 953 }
2526 v = codec_tuple(PyUnicode_AsUnicodeEscapeString(str), 954 v = codec_tuple(PyUnicode_AsUnicodeEscapeString(str),
2527 PyUnicode_GET_LENGTH(str)); 955 PyUnicode_GET_LENGTH(str));
2528 Py_DECREF(str); 956 Py_DECREF(str);
2529 return v; 957 return v;
2530 } 958 }
2531 959
2532 /*[clinic input] 960 /*[clinic input]
2533 _codecs.Codecs.raw_unicode_escape_encode 961 _codecs.raw_unicode_escape_encode
2534 str: object 962 str: object
2535 [ 963 errors: str(nullable=True) = NULL
2536 errors: str(nullable=True) 964 /
2537 ] 965 [clinic start generated code]*/
2538 / 966
2539 [clinic start generated code]*/ 967 static PyObject *
2540 968 _codecs_raw_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str,
2541 PyDoc_STRVAR(_codecs_Codecs_raw_unicode_escape_encode__doc__, 969 const char *errors)
2542 "raw_unicode_escape_encode(str, [errors])"); 970 /*[clinic end generated code: output=fec4e39d6ec37a62 input=022a856c6bbac275]*/
2543
2544 #define _CODECS_CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF \
2545 {"raw_unicode_escape_encode", (PyCFunction)_codecs_Codecs_raw_unicode_escape _encode, METH_VARARGS, _codecs_Codecs_raw_unicode_escape_encode__doc__},
2546
2547 static PyObject *
2548 _codecs_Codecs_raw_unicode_escape_encode_impl(PyObject *self, PyObject *str, int group_right_1, const char *errors);
2549
2550 static PyObject *
2551 _codecs_Codecs_raw_unicode_escape_encode(PyObject *self, PyObject *args)
2552 {
2553 PyObject *return_value = NULL;
2554 PyObject *str;
2555 int group_right_1 = 0;
2556 const char *errors = NULL;
2557
2558 switch (PyTuple_Size(args)) {
2559 case 1:
2560 if (!PyArg_ParseTuple(args, "O:raw_unicode_escape_encode", &str))
2561 return NULL;
2562 break;
2563 case 2:
2564 if (!PyArg_ParseTuple(args, "Oz:raw_unicode_escape_encode", &str, &e rrors))
2565 return NULL;
2566 group_right_1 = 1;
2567 break;
2568 default:
2569 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.raw_unicode_escape_ encode requires 1 to 2 arguments");
2570 return NULL;
2571 }
2572 return_value = _codecs_Codecs_raw_unicode_escape_encode_impl(self, str, grou p_right_1, errors);
2573
2574 return return_value;
2575 }
2576
2577 static PyObject *
2578 _codecs_Codecs_raw_unicode_escape_encode_impl(PyObject *self, PyObject *str, int group_right_1, const char *errors)
2579 /*[clinic end generated code: checksum=71322526bde049be177d1cb0c224af1d542cea22] */
2580 { 971 {
2581 PyObject *v; 972 PyObject *v;
2582 973
2583 str = PyUnicode_FromObject(str); 974 str = PyUnicode_FromObject(str);
2584 if (str == NULL || PyUnicode_READY(str) < 0) { 975 if (str == NULL || PyUnicode_READY(str) < 0) {
2585 Py_XDECREF(str); 976 Py_XDECREF(str);
2586 return NULL; 977 return NULL;
2587 } 978 }
2588 v = codec_tuple(PyUnicode_AsRawUnicodeEscapeString(str), 979 v = codec_tuple(PyUnicode_AsRawUnicodeEscapeString(str),
2589 PyUnicode_GET_LENGTH(str)); 980 PyUnicode_GET_LENGTH(str));
2590 Py_DECREF(str); 981 Py_DECREF(str);
2591 return v; 982 return v;
2592 } 983 }
2593 984
2594 /*[clinic input] 985 /*[clinic input]
2595 _codecs.Codecs.latin_1_encode 986 _codecs.latin_1_encode
2596 str: object 987 str: object
2597 [ 988 errors: str(nullable=True) = NULL
2598 errors: str(nullable=True) 989 /
2599 ] 990 [clinic start generated code]*/
2600 / 991
2601 [clinic start generated code]*/ 992 static PyObject *
2602 993 _codecs_latin_1_encode_impl(PyModuleDef *module, PyObject *str,
2603 PyDoc_STRVAR(_codecs_Codecs_latin_1_encode__doc__, 994 const char *errors)
2604 "latin_1_encode(str, [errors])"); 995 /*[clinic end generated code: output=ecf00eb8e48c889c input=e2ec958e195e3f30]*/
2605
2606 #define _CODECS_CODECS_LATIN_1_ENCODE_METHODDEF \
2607 {"latin_1_encode", (PyCFunction)_codecs_Codecs_latin_1_encode, METH_VARARGS, _codecs_Codecs_latin_1_encode__doc__},
2608
2609 static PyObject *
2610 _codecs_Codecs_latin_1_encode_impl(PyObject *self, PyObject *str, int group_righ t_1, const char *errors);
2611
2612 static PyObject *
2613 _codecs_Codecs_latin_1_encode(PyObject *self, PyObject *args)
2614 {
2615 PyObject *return_value = NULL;
2616 PyObject *str;
2617 int group_right_1 = 0;
2618 const char *errors = NULL;
2619
2620 switch (PyTuple_Size(args)) {
2621 case 1:
2622 if (!PyArg_ParseTuple(args, "O:latin_1_encode", &str))
2623 return NULL;
2624 break;
2625 case 2:
2626 if (!PyArg_ParseTuple(args, "Oz:latin_1_encode", &str, &errors))
2627 return NULL;
2628 group_right_1 = 1;
2629 break;
2630 default:
2631 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.latin_1_encode requ ires 1 to 2 arguments");
2632 return NULL;
2633 }
2634 return_value = _codecs_Codecs_latin_1_encode_impl(self, str, group_right_1, errors);
2635
2636 return return_value;
2637 }
2638
2639 static PyObject *
2640 _codecs_Codecs_latin_1_encode_impl(PyObject *self, PyObject *str, int group_righ t_1, const char *errors)
2641 /*[clinic end generated code: checksum=7b73f06986d320799647494fb73c9f606f95ff53] */
2642 { 996 {
2643 PyObject *v; 997 PyObject *v;
2644 998
2645 str = PyUnicode_FromObject(str); 999 str = PyUnicode_FromObject(str);
2646 if (str == NULL || PyUnicode_READY(str) < 0) { 1000 if (str == NULL || PyUnicode_READY(str) < 0) {
2647 Py_XDECREF(str); 1001 Py_XDECREF(str);
2648 return NULL; 1002 return NULL;
2649 } 1003 }
2650 v = codec_tuple(_PyUnicode_AsLatin1String(str, errors), 1004 v = codec_tuple(_PyUnicode_AsLatin1String(str, errors),
2651 PyUnicode_GET_LENGTH(str)); 1005 PyUnicode_GET_LENGTH(str));
2652 Py_DECREF(str); 1006 Py_DECREF(str);
2653 return v; 1007 return v;
2654 } 1008 }
2655 1009
2656 /*[clinic input] 1010 /*[clinic input]
2657 _codecs.Codecs.ascii_encode 1011 _codecs.ascii_encode
2658 str: object 1012 str: object
2659 [ 1013 errors: str(nullable=True) = NULL
2660 errors: str(nullable=True) 1014 /
2661 ] 1015 [clinic start generated code]*/
2662 / 1016
2663 [clinic start generated code]*/ 1017 static PyObject *
2664 1018 _codecs_ascii_encode_impl(PyModuleDef *module, PyObject *str,
2665 PyDoc_STRVAR(_codecs_Codecs_ascii_encode__doc__, 1019 const char *errors)
2666 "ascii_encode(str, [errors])"); 1020 /*[clinic end generated code: output=a9d18fc6b6b91cfb input=536afe3b176f737b]*/
2667
2668 #define _CODECS_CODECS_ASCII_ENCODE_METHODDEF \
2669 {"ascii_encode", (PyCFunction)_codecs_Codecs_ascii_encode, METH_VARARGS, _co decs_Codecs_ascii_encode__doc__},
2670
2671 static PyObject *
2672 _codecs_Codecs_ascii_encode_impl(PyObject *self, PyObject *str, int group_right_ 1, const char *errors);
2673
2674 static PyObject *
2675 _codecs_Codecs_ascii_encode(PyObject *self, PyObject *args)
2676 {
2677 PyObject *return_value = NULL;
2678 PyObject *str;
2679 int group_right_1 = 0;
2680 const char *errors = NULL;
2681
2682 switch (PyTuple_Size(args)) {
2683 case 1:
2684 if (!PyArg_ParseTuple(args, "O:ascii_encode", &str))
2685 return NULL;
2686 break;
2687 case 2:
2688 if (!PyArg_ParseTuple(args, "Oz:ascii_encode", &str, &errors))
2689 return NULL;
2690 group_right_1 = 1;
2691 break;
2692 default:
2693 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.ascii_encode requir es 1 to 2 arguments");
2694 return NULL;
2695 }
2696 return_value = _codecs_Codecs_ascii_encode_impl(self, str, group_right_1, er rors);
2697
2698 return return_value;
2699 }
2700
2701 static PyObject *
2702 _codecs_Codecs_ascii_encode_impl(PyObject *self, PyObject *str, int group_right_ 1, const char *errors)
2703 /*[clinic end generated code: checksum=7dce795060ed9de4a012740ff404d23ad3417cbf] */
2704 { 1021 {
2705 PyObject *v; 1022 PyObject *v;
2706 1023
2707 str = PyUnicode_FromObject(str); 1024 str = PyUnicode_FromObject(str);
2708 if (str == NULL || PyUnicode_READY(str) < 0) { 1025 if (str == NULL || PyUnicode_READY(str) < 0) {
2709 Py_XDECREF(str); 1026 Py_XDECREF(str);
2710 return NULL; 1027 return NULL;
2711 } 1028 }
2712 v = codec_tuple(_PyUnicode_AsASCIIString(str, errors), 1029 v = codec_tuple(_PyUnicode_AsASCIIString(str, errors),
2713 PyUnicode_GET_LENGTH(str)); 1030 PyUnicode_GET_LENGTH(str));
2714 Py_DECREF(str); 1031 Py_DECREF(str);
2715 return v; 1032 return v;
2716 } 1033 }
2717 1034
2718 /*[clinic input] 1035 /*[clinic input]
2719 _codecs.Codecs.charmap_encode 1036 _codecs.charmap_encode
2720 str: object 1037 str: object
2721 [ 1038 errors: str(nullable=True) = NULL
2722 errors: str(nullable=True) 1039 mapping: object = NULL
2723 [ 1040 /
2724 mapping: object = None 1041 [clinic start generated code]*/
2725 ] 1042
2726 ] 1043 static PyObject *
2727 / 1044 _codecs_charmap_encode_impl(PyModuleDef *module, PyObject *str,
2728 [clinic start generated code]*/ 1045 const char *errors, PyObject *mapping)
2729 1046 /*[clinic end generated code: output=14ca42b83853c643 input=6cfea1a4be31cde1]*/
2730 PyDoc_STRVAR(_codecs_Codecs_charmap_encode__doc__,
2731 "charmap_encode(str, [errors, [mapping=None]])");
2732
2733 #define _CODECS_CODECS_CHARMAP_ENCODE_METHODDEF \
2734 {"charmap_encode", (PyCFunction)_codecs_Codecs_charmap_encode, METH_VARARGS, _codecs_Codecs_charmap_encode__doc__},
2735
2736 static PyObject *
2737 _codecs_Codecs_charmap_encode_impl(PyObject *self, PyObject *str, int group_righ t_1, const char *errors, int group_right_2, PyObject *mapping);
2738
2739 static PyObject *
2740 _codecs_Codecs_charmap_encode(PyObject *self, PyObject *args)
2741 {
2742 PyObject *return_value = NULL;
2743 PyObject *str;
2744 int group_right_1 = 0;
2745 const char *errors = NULL;
2746 int group_right_2 = 0;
2747 PyObject *mapping = Py_None;
2748
2749 switch (PyTuple_Size(args)) {
2750 case 1:
2751 if (!PyArg_ParseTuple(args, "O:charmap_encode", &str))
2752 return NULL;
2753 break;
2754 case 2:
2755 if (!PyArg_ParseTuple(args, "Oz:charmap_encode", &str, &errors))
2756 return NULL;
2757 group_right_1 = 1;
2758 break;
2759 case 3:
2760 if (!PyArg_ParseTuple(args, "OzO:charmap_encode", &str, &errors, &ma pping))
2761 return NULL;
2762 group_right_1 = 1;
2763 group_right_2 = 1;
2764 break;
2765 default:
2766 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.charmap_encode requ ires 1 to 3 arguments");
2767 return NULL;
2768 }
2769 return_value = _codecs_Codecs_charmap_encode_impl(self, str, group_right_1, errors, group_right_2, mapping);
2770
2771 return return_value;
2772 }
2773
2774 static PyObject *
2775 _codecs_Codecs_charmap_encode_impl(PyObject *self, PyObject *str, int group_righ t_1, const char *errors, int group_right_2, PyObject *mapping)
2776 /*[clinic end generated code: checksum=cb386acf850159e17e2b30528fa0a4d2e6d1c809] */
2777 { 1047 {
2778 PyObject *v; 1048 PyObject *v;
2779 1049
2780 if (mapping == Py_None) 1050 if (mapping == Py_None)
2781 mapping = NULL; 1051 mapping = NULL;
2782 1052
2783 str = PyUnicode_FromObject(str); 1053 str = PyUnicode_FromObject(str);
2784 if (str == NULL || PyUnicode_READY(str) < 0) { 1054 if (str == NULL || PyUnicode_READY(str) < 0) {
2785 Py_XDECREF(str); 1055 Py_XDECREF(str);
2786 return NULL; 1056 return NULL;
2787 } 1057 }
2788 v = codec_tuple(_PyUnicode_EncodeCharmap(str, mapping, errors), 1058 v = codec_tuple(_PyUnicode_EncodeCharmap(str, mapping, errors),
2789 PyUnicode_GET_LENGTH(str)); 1059 PyUnicode_GET_LENGTH(str));
2790 Py_DECREF(str); 1060 Py_DECREF(str);
2791 return v; 1061 return v;
2792 } 1062 }
2793 1063
2794 /*[clinic input] 1064 /*[clinic input]
2795 _codecs.Codecs.charmap_build 1065 _codecs.charmap_build
2796 map: unicode 1066 map: unicode
2797 / 1067 /
2798 [clinic start generated code]*/ 1068 [clinic start generated code]*/
2799 1069
2800 PyDoc_STRVAR(_codecs_Codecs_charmap_build__doc__, 1070 static PyObject *
2801 "charmap_build(map)"); 1071 _codecs_charmap_build_impl(PyModuleDef *module, PyObject *map)
2802 1072 /*[clinic end generated code: output=9485b58fa44afa6a input=d91a91d1717dbc6d]*/
2803 #define _CODECS_CODECS_CHARMAP_BUILD_METHODDEF \
2804 {"charmap_build", (PyCFunction)_codecs_Codecs_charmap_build, METH_VARARGS, _ codecs_Codecs_charmap_build__doc__},
2805
2806 static PyObject *
2807 _codecs_Codecs_charmap_build_impl(PyObject *self, PyObject *map);
2808
2809 static PyObject *
2810 _codecs_Codecs_charmap_build(PyObject *self, PyObject *args)
2811 {
2812 PyObject *return_value = NULL;
2813 PyObject *map;
2814
2815 if (!PyArg_ParseTuple(args,
2816 "U:charmap_build",
2817 &map))
2818 goto exit;
2819 return_value = _codecs_Codecs_charmap_build_impl(self, map);
2820
2821 exit:
2822 return return_value;
2823 }
2824
2825 static PyObject *
2826 _codecs_Codecs_charmap_build_impl(PyObject *self, PyObject *map)
2827 /*[clinic end generated code: checksum=a80038590a254024bf45acd290b3b5ea4695c8f7] */
2828 { 1073 {
2829 return PyUnicode_BuildEncodingMap(map); 1074 return PyUnicode_BuildEncodingMap(map);
2830 } 1075 }
2831 1076
2832 #ifdef HAVE_MBCS 1077 #ifdef HAVE_MBCS
2833 1078
2834 /*[clinic input] 1079 /*[clinic input]
2835 _codecs.Codecs.mbcs_encode 1080 _codecs.mbcs_encode
2836 str: object 1081 str: object
2837 [ 1082 errors: str(nullable=True) = NULL
2838 errors: str(nullable=True) 1083 /
2839 ] 1084 [clinic start generated code]*/
2840 / 1085
2841 [clinic start generated code]*/ 1086 static PyObject *
2842 1087 _codecs_mbcs_encode_impl(PyModuleDef *module, PyObject *str,
2843 PyDoc_STRVAR(_codecs_Codecs_mbcs_encode__doc__, 1088 const char *errors)
2844 "mbcs_encode(str, [errors])"); 1089 /*[clinic end generated code: output=d1a013bc68798bd7 input=30a1cf44d9315ec9]*/
2845
2846 #define _CODECS_CODECS_MBCS_ENCODE_METHODDEF \
2847 {"mbcs_encode", (PyCFunction)_codecs_Codecs_mbcs_encode, METH_VARARGS, _code cs_Codecs_mbcs_encode__doc__},
2848
2849 static PyObject *
2850 _codecs_Codecs_mbcs_encode_impl(PyObject *self, PyObject *str, int group_right_1 , const char *errors);
2851
2852 static PyObject *
2853 _codecs_Codecs_mbcs_encode(PyObject *self, PyObject *args)
2854 {
2855 PyObject *return_value = NULL;
2856 PyObject *str;
2857 int group_right_1 = 0;
2858 const char *errors = NULL;
2859
2860 switch (PyTuple_Size(args)) {
2861 case 1:
2862 if (!PyArg_ParseTuple(args, "O:mbcs_encode", &str))
2863 return NULL;
2864 break;
2865 case 2:
2866 if (!PyArg_ParseTuple(args, "Oz:mbcs_encode", &str, &errors))
2867 return NULL;
2868 group_right_1 = 1;
2869 break;
2870 default:
2871 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.mbcs_encode require s 1 to 2 arguments");
2872 return NULL;
2873 }
2874 return_value = _codecs_Codecs_mbcs_encode_impl(self, str, group_right_1, err ors);
2875
2876 return return_value;
2877 }
2878
2879 static PyObject *
2880 _codecs_Codecs_mbcs_encode_impl(PyObject *self, PyObject *str, int group_right_1 , const char *errors)
2881 /*[clinic end generated code: checksum=1c89fd3be1247aaecc1d17bd0fd3c4132f8fa45e] */
2882 { 1090 {
2883 PyObject *v; 1091 PyObject *v;
2884 1092
2885 str = PyUnicode_FromObject(str); 1093 str = PyUnicode_FromObject(str);
2886 if (str == NULL || PyUnicode_READY(str) < 0) { 1094 if (str == NULL || PyUnicode_READY(str) < 0) {
2887 Py_XDECREF(str); 1095 Py_XDECREF(str);
2888 return NULL; 1096 return NULL;
2889 } 1097 }
2890 v = codec_tuple(PyUnicode_EncodeCodePage(CP_ACP, str, errors), 1098 v = codec_tuple(PyUnicode_EncodeCodePage(CP_ACP, str, errors),
2891 PyUnicode_GET_LENGTH(str)); 1099 PyUnicode_GET_LENGTH(str));
2892 Py_DECREF(str); 1100 Py_DECREF(str);
2893 return v; 1101 return v;
2894 } 1102 }
2895 1103
2896 /*[clinic input] 1104 /*[clinic input]
2897 _codecs.Codecs.code_page_encode 1105 _codecs.code_page_encode
2898 code_page: int 1106 code_page: int
2899 str: object 1107 str: object
2900 [ 1108 errors: str(nullable=True) = NULL
2901 errors: str(nullable=True) 1109 /
2902 ] 1110 [clinic start generated code]*/
2903 / 1111
2904 [clinic start generated code]*/ 1112 static PyObject *
2905 1113 _codecs_code_page_encode_impl(PyModuleDef *module, int code_page,
2906 PyDoc_STRVAR(_codecs_Codecs_code_page_encode__doc__, 1114 PyObject *str, const char *errors)
2907 "code_page_encode(code_page, str, [errors])"); 1115 /*[clinic end generated code: output=3b406618dbfbce25 input=b0c72790c2e2ce28]*/
2908
2909 #define _CODECS_CODECS_CODE_PAGE_ENCODE_METHODDEF \
2910 {"code_page_encode", (PyCFunction)_codecs_Codecs_code_page_encode, METH_VARA RGS, _codecs_Codecs_code_page_encode__doc__},
2911
2912 static PyObject *
2913 _codecs_Codecs_code_page_encode_impl(PyObject *self, int code_page, PyObject *st r, int group_right_1, const char *errors);
2914
2915 static PyObject *
2916 _codecs_Codecs_code_page_encode(PyObject *self, PyObject *args)
2917 {
2918 PyObject *return_value = NULL;
2919 int code_page;
2920 PyObject *str;
2921 int group_right_1 = 0;
2922 const char *errors = NULL;
2923
2924 switch (PyTuple_Size(args)) {
2925 case 2:
2926 if (!PyArg_ParseTuple(args, "iO:code_page_encode", &code_page, &str) )
2927 return NULL;
2928 break;
2929 case 3:
2930 if (!PyArg_ParseTuple(args, "iOz:code_page_encode", &code_page, &str , &errors))
2931 return NULL;
2932 group_right_1 = 1;
2933 break;
2934 default:
2935 PyErr_SetString(PyExc_TypeError, "_codecs.Codecs.code_page_encode re quires 2 to 3 arguments");
2936 return NULL;
2937 }
2938 return_value = _codecs_Codecs_code_page_encode_impl(self, code_page, str, gr oup_right_1, errors);
2939
2940 return return_value;
2941 }
2942
2943 static PyObject *
2944 _codecs_Codecs_code_page_encode_impl(PyObject *self, int code_page, PyObject *st r, int group_right_1, const char *errors)
2945 /*[clinic end generated code: checksum=dd0a2b0c37f9740a3aae914b8bf089d7af12f8da] */
2946 { 1116 {
2947 PyObject *v; 1117 PyObject *v;
2948 1118
2949 str = PyUnicode_FromObject(str); 1119 str = PyUnicode_FromObject(str);
2950 if (str == NULL || PyUnicode_READY(str) < 0) { 1120 if (str == NULL || PyUnicode_READY(str) < 0) {
2951 Py_XDECREF(str); 1121 Py_XDECREF(str);
2952 return NULL; 1122 return NULL;
2953 } 1123 }
2954 v = codec_tuple(PyUnicode_EncodeCodePage(code_page, 1124 v = codec_tuple(PyUnicode_EncodeCodePage(code_page,
2955 str, 1125 str,
2956 errors), 1126 errors),
2957 PyUnicode_GET_LENGTH(str)); 1127 PyUnicode_GET_LENGTH(str));
2958 Py_DECREF(str); 1128 Py_DECREF(str);
2959 return v; 1129 return v;
2960 } 1130 }
2961 1131
2962 #endif /* HAVE_MBCS */ 1132 #endif /* HAVE_MBCS */
2963 1133
2964 /* --- Error handler registry --------------------------------------------- */ 1134 /* --- Error handler registry --------------------------------------------- */
2965 1135
2966 /*[clinic input] 1136 /*[clinic input]
2967 _codecs.Codecs.register_error 1137 _codecs.register_error
1138 errors: str
1139 handler: object
1140 /
1141
1142 Register the specified error handler under the name errors.
1143
1144 handler must be a callable object, that will be called with an exception
1145 instance containing information about the location of the encoding/decoding
1146 error and must return a (replacement, new position) tuple.
1147 [clinic start generated code]*/
1148
1149 static PyObject *
1150 _codecs_register_error_impl(PyModuleDef *module, const char *errors,
1151 PyObject *handler)
1152 /*[clinic end generated code: output=be00d3b1849ce68a input=5e6709203c2e33fe]*/
1153 {
1154 if (PyCodec_RegisterError(errors, handler))
1155 return NULL;
1156 Py_RETURN_NONE;
1157 }
1158
1159 /*[clinic input]
1160 _codecs.lookup_error
2968 name: str 1161 name: str
2969 handler: object 1162 /
2970 / 1163
2971 1164 lookup_error(errors) -> handler
2972 Register the specified error handler.
2973
2974 Register the specified error handler under the name errors. handler must be a
2975 callable object, that will be called with an exception instance containing
2976 information about the location of the encoding/decoding error and must return a
2977 (replacement, new position) tuple.
2978 [clinic start generated code]*/
2979
2980 PyDoc_STRVAR(_codecs_Codecs_register_error__doc__,
2981 "register_error(name, handler)\n"
2982 "Register the specified error handler.\n"
2983 "\n"
2984 "Register the specified error handler under the name errors. handler must be a\n "
2985 "callable object, that will be called with an exception instance containing\n"
2986 "information about the location of the encoding/decoding error and must return a \n"
2987 "(replacement, new position) tuple.");
2988
2989 #define _CODECS_CODECS_REGISTER_ERROR_METHODDEF \
2990 {"register_error", (PyCFunction)_codecs_Codecs_register_error, METH_VARARGS, _codecs_Codecs_register_error__doc__},
2991
2992 static PyObject *
2993 _codecs_Codecs_register_error_impl(PyObject *self, const char *name, PyObject *h andler);
2994
2995 static PyObject *
2996 _codecs_Codecs_register_error(PyObject *self, PyObject *args)
2997 {
2998 PyObject *return_value = NULL;
2999 const char *name;
3000 PyObject *handler;
3001
3002 if (!PyArg_ParseTuple(args,
3003 "sO:register_error",
3004 &name, &handler))
3005 goto exit;
3006 return_value = _codecs_Codecs_register_error_impl(self, name, handler);
3007
3008 exit:
3009 return return_value;
3010 }
3011
3012 static PyObject *
3013 _codecs_Codecs_register_error_impl(PyObject *self, const char *name, PyObject *h andler)
3014 /*[clinic end generated code: checksum=2f69fc4cacfab945ede1263f21f3522bd6a6e776] */
3015 {
3016 if (PyCodec_RegisterError(name, handler))
3017 return NULL;
3018 Py_RETURN_NONE;
3019 }
3020
3021 /*[clinic input]
3022 _codecs.Codecs.lookup_error
3023 name: str
3024 /
3025
3026 Return the error handler.
3027 1165
3028 Return the error handler for the specified error handling name or raise a 1166 Return the error handler for the specified error handling name or raise a
3029 LookupError, if no handler exists under this name. 1167 LookupError, if no handler exists under this name.
3030 [clinic start generated code]*/ 1168 [clinic start generated code]*/
3031 1169
3032 PyDoc_STRVAR(_codecs_Codecs_lookup_error__doc__, 1170 static PyObject *
3033 "lookup_error(name)\n" 1171 _codecs_lookup_error_impl(PyModuleDef *module, const char *name)
3034 "Return the error handler.\n" 1172 /*[clinic end generated code: output=731e6df8c83c6158 input=4775dd65e6235aba]*/
3035 "\n"
3036 "Return the error handler for the specified error handling name or raise a\n"
3037 "LookupError, if no handler exists under this name.");
3038
3039 #define _CODECS_CODECS_LOOKUP_ERROR_METHODDEF \
3040 {"lookup_error", (PyCFunction)_codecs_Codecs_lookup_error, METH_VARARGS, _co decs_Codecs_lookup_error__doc__},
3041
3042 static PyObject *
3043 _codecs_Codecs_lookup_error_impl(PyObject *self, const char *name);
3044
3045 static PyObject *
3046 _codecs_Codecs_lookup_error(PyObject *self, PyObject *args)
3047 {
3048 PyObject *return_value = NULL;
3049 const char *name;
3050
3051 if (!PyArg_ParseTuple(args,
3052 "s:lookup_error",
3053 &name))
3054 goto exit;
3055 return_value = _codecs_Codecs_lookup_error_impl(self, name);
3056
3057 exit:
3058 return return_value;
3059 }
3060
3061 static PyObject *
3062 _codecs_Codecs_lookup_error_impl(PyObject *self, const char *name)
3063 /*[clinic end generated code: checksum=baf3de5707dfd143b51a672e6d6931d0850756a8] */
3064 { 1173 {
3065 return PyCodec_LookupError(name); 1174 return PyCodec_LookupError(name);
3066 } 1175 }
3067 1176
3068 /* --- Module API --------------------------------------------------------- */ 1177 /* --- Module API --------------------------------------------------------- */
3069 1178
3070 static PyMethodDef _codecs_functions[] = { 1179 static PyMethodDef _codecs_functions[] = {
3071 {"register", codec_register, METH_O, 1180 _CODECS_REGISTER_METHODDEF
3072 register__doc__}, 1181 _CODECS_LOOKUP_METHODDEF
3073 _CODECS_CODECS_LOOKUP_METHODDEF 1182 _CODECS_ENCODE_METHODDEF
3074 _CODECS_CODECS_ENCODE_METHODDEF 1183 _CODECS_DECODE_METHODDEF
3075 _CODECS_CODECS_DECODE_METHODDEF 1184 _CODECS_ESCAPE_ENCODE_METHODDEF
3076 _CODECS_CODECS_ESCAPE_DECODE_METHODDEF 1185 _CODECS_ESCAPE_DECODE_METHODDEF
3077 _CODECS_CODECS_ESCAPE_ENCODE_METHODDEF 1186 _CODECS_UTF_8_ENCODE_METHODDEF
3078 _CODECS_CODECS_UTF_8_ENCODE_METHODDEF 1187 _CODECS_UTF_8_DECODE_METHODDEF
3079 _CODECS_CODECS_UTF_8_DECODE_METHODDEF 1188 _CODECS_UTF_7_ENCODE_METHODDEF
3080 _CODECS_CODECS_UTF_7_ENCODE_METHODDEF 1189 _CODECS_UTF_7_DECODE_METHODDEF
3081 _CODECS_CODECS_UTF_7_DECODE_METHODDEF 1190 _CODECS_UTF_16_ENCODE_METHODDEF
3082 _CODECS_CODECS_UTF_16_ENCODE_METHODDEF 1191 _CODECS_UTF_16_LE_ENCODE_METHODDEF
3083 _CODECS_CODECS_UTF_16_LE_ENCODE_METHODDEF 1192 _CODECS_UTF_16_BE_ENCODE_METHODDEF
3084 _CODECS_CODECS_UTF_16_BE_ENCODE_METHODDEF 1193 _CODECS_UTF_16_DECODE_METHODDEF
3085 _CODECS_CODECS_UTF_16_DECODE_METHODDEF 1194 _CODECS_UTF_16_LE_DECODE_METHODDEF
3086 _CODECS_CODECS_UTF_16_LE_DECODE_METHODDEF 1195 _CODECS_UTF_16_BE_DECODE_METHODDEF
3087 _CODECS_CODECS_UTF_16_BE_DECODE_METHODDEF 1196 _CODECS_UTF_16_EX_DECODE_METHODDEF
3088 _CODECS_CODECS_UTF_16_EX_DECODE_METHODDEF 1197 _CODECS_UTF_32_ENCODE_METHODDEF
3089 _CODECS_CODECS_UTF_32_ENCODE_METHODDEF 1198 _CODECS_UTF_32_LE_ENCODE_METHODDEF
3090 _CODECS_CODECS_UTF_32_LE_ENCODE_METHODDEF 1199 _CODECS_UTF_32_BE_ENCODE_METHODDEF
3091 _CODECS_CODECS_UTF_32_BE_ENCODE_METHODDEF 1200 _CODECS_UTF_32_DECODE_METHODDEF
3092 _CODECS_CODECS_UTF_32_DECODE_METHODDEF 1201 _CODECS_UTF_32_LE_DECODE_METHODDEF
3093 _CODECS_CODECS_UTF_32_LE_DECODE_METHODDEF 1202 _CODECS_UTF_32_BE_DECODE_METHODDEF
3094 _CODECS_CODECS_UTF_32_BE_DECODE_METHODDEF 1203 _CODECS_UTF_32_EX_DECODE_METHODDEF
3095 _CODECS_CODECS_UTF_32_EX_DECODE_METHODDEF 1204 _CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF
3096 _CODECS_CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF 1205 _CODECS_UNICODE_ESCAPE_DECODE_METHODDEF
3097 _CODECS_CODECS_UNICODE_ESCAPE_DECODE_METHODDEF 1206 _CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF
3098 _CODECS_CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF 1207 _CODECS_UNICODE_INTERNAL_DECODE_METHODDEF
3099 _CODECS_CODECS_UNICODE_INTERNAL_DECODE_METHODDEF 1208 _CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF
3100 _CODECS_CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF 1209 _CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF
3101 _CODECS_CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF 1210 _CODECS_LATIN_1_ENCODE_METHODDEF
3102 _CODECS_CODECS_LATIN_1_ENCODE_METHODDEF 1211 _CODECS_LATIN_1_DECODE_METHODDEF
3103 _CODECS_CODECS_LATIN_1_DECODE_METHODDEF 1212 _CODECS_ASCII_ENCODE_METHODDEF
3104 _CODECS_CODECS_ASCII_ENCODE_METHODDEF 1213 _CODECS_ASCII_DECODE_METHODDEF
3105 _CODECS_CODECS_ASCII_DECODE_METHODDEF 1214 _CODECS_CHARMAP_ENCODE_METHODDEF
3106 _CODECS_CODECS_CHARMAP_ENCODE_METHODDEF 1215 _CODECS_CHARMAP_DECODE_METHODDEF
3107 _CODECS_CODECS_CHARMAP_DECODE_METHODDEF 1216 _CODECS_CHARMAP_BUILD_METHODDEF
3108 _CODECS_CODECS_CHARMAP_BUILD_METHODDEF 1217 _CODECS_READBUFFER_ENCODE_METHODDEF
3109 _CODECS_CODECS_READBUFFER_ENCODE_METHODDEF 1218 _CODECS_MBCS_ENCODE_METHODDEF
3110 #ifdef HAVE_MBCS 1219 _CODECS_MBCS_DECODE_METHODDEF
3111 _CODECS_CODECS_MBCS_ENCODE_METHODDEF 1220 _CODECS_CODE_PAGE_ENCODE_METHODDEF
3112 _CODECS_CODECS_MBCS_DECODE_METHODDEF 1221 _CODECS_CODE_PAGE_DECODE_METHODDEF
3113 _CODECS_CODECS_CODE_PAGE_ENCODE_METHODDEF 1222 _CODECS_REGISTER_ERROR_METHODDEF
3114 _CODECS_CODECS_CODE_PAGE_DECODE_METHODDEF 1223 _CODECS_LOOKUP_ERROR_METHODDEF
3115 #endif 1224 _CODECS__FORGET_CODEC_METHODDEF
3116 _CODECS_CODECS_REGISTER_ERROR_METHODDEF
3117 _CODECS_CODECS_LOOKUP_ERROR_METHODDEF
3118 {NULL, NULL} /* sentinel */ 1225 {NULL, NULL} /* sentinel */
3119 }; 1226 };
3120 1227
3121 static struct PyModuleDef codecsmodule = { 1228 static struct PyModuleDef codecsmodule = {
3122 PyModuleDef_HEAD_INIT, 1229 PyModuleDef_HEAD_INIT,
3123 "_codecs", 1230 "_codecs",
3124 NULL, 1231 NULL,
3125 -1, 1232 -1,
3126 _codecs_functions, 1233 _codecs_functions,
3127 NULL, 1234 NULL,
3128 NULL, 1235 NULL,
3129 NULL, 1236 NULL,
3130 NULL 1237 NULL
3131 }; 1238 };
3132 1239
3133 PyMODINIT_FUNC 1240 PyMODINIT_FUNC
3134 PyInit__codecs(void) 1241 PyInit__codecs(void)
3135 { 1242 {
3136 return PyModule_Create(&codecsmodule); 1243 return PyModule_Create(&codecsmodule);
3137 } 1244 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+