blob: 33f82d4da8b6c90cf34ff5fd1bd2d9fbb90804af [file] [log] [blame]
Brett Cannon1eb32c22014-10-10 16:26:45 -04001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(array_array___copy____doc__,
6"__copy__($self, /)\n"
7"--\n"
8"\n"
9"Return a copy of the array.");
10
11#define ARRAY_ARRAY___COPY___METHODDEF \
12 {"__copy__", (PyCFunction)array_array___copy__, METH_NOARGS, array_array___copy____doc__},
13
14static PyObject *
15array_array___copy___impl(arrayobject *self);
16
17static PyObject *
18array_array___copy__(arrayobject *self, PyObject *Py_UNUSED(ignored))
19{
20 return array_array___copy___impl(self);
21}
22
23PyDoc_STRVAR(array_array___deepcopy____doc__,
24"__deepcopy__($self, unused, /)\n"
25"--\n"
26"\n"
27"Return a copy of the array.");
28
29#define ARRAY_ARRAY___DEEPCOPY___METHODDEF \
30 {"__deepcopy__", (PyCFunction)array_array___deepcopy__, METH_O, array_array___deepcopy____doc__},
31
32PyDoc_STRVAR(array_array_count__doc__,
33"count($self, v, /)\n"
34"--\n"
35"\n"
36"Return number of occurrences of v in the array.");
37
38#define ARRAY_ARRAY_COUNT_METHODDEF \
39 {"count", (PyCFunction)array_array_count, METH_O, array_array_count__doc__},
40
41PyDoc_STRVAR(array_array_index__doc__,
42"index($self, v, /)\n"
43"--\n"
44"\n"
45"Return index of first occurrence of v in the array.");
46
47#define ARRAY_ARRAY_INDEX_METHODDEF \
48 {"index", (PyCFunction)array_array_index, METH_O, array_array_index__doc__},
49
50PyDoc_STRVAR(array_array_remove__doc__,
51"remove($self, v, /)\n"
52"--\n"
53"\n"
54"Remove the first occurrence of v in the array.");
55
56#define ARRAY_ARRAY_REMOVE_METHODDEF \
57 {"remove", (PyCFunction)array_array_remove, METH_O, array_array_remove__doc__},
58
59PyDoc_STRVAR(array_array_pop__doc__,
60"pop($self, i=-1, /)\n"
61"--\n"
62"\n"
63"Return the i-th element and delete it from the array.\n"
64"\n"
65"i defaults to -1.");
66
67#define ARRAY_ARRAY_POP_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +020068 {"pop", (PyCFunction)(void(*)(void))array_array_pop, METH_FASTCALL, array_array_pop__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -040069
70static PyObject *
71array_array_pop_impl(arrayobject *self, Py_ssize_t i);
72
73static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020074array_array_pop(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
Brett Cannon1eb32c22014-10-10 16:26:45 -040075{
76 PyObject *return_value = NULL;
77 Py_ssize_t i = -1;
78
Serhiy Storchaka4fa95912019-01-11 16:01:14 +020079 if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
Victor Stinner259f0e42017-01-17 01:35:17 +010080 goto exit;
81 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +020082 if (nargs < 1) {
83 goto skip_optional;
84 }
85 if (PyFloat_Check(args[0])) {
86 PyErr_SetString(PyExc_TypeError,
87 "integer argument expected, got float" );
88 goto exit;
89 }
90 {
91 Py_ssize_t ival = -1;
92 PyObject *iobj = PyNumber_Index(args[0]);
93 if (iobj != NULL) {
94 ival = PyLong_AsSsize_t(iobj);
95 Py_DECREF(iobj);
96 }
97 if (ival == -1 && PyErr_Occurred()) {
98 goto exit;
99 }
100 i = ival;
101 }
102skip_optional:
Brett Cannon1eb32c22014-10-10 16:26:45 -0400103 return_value = array_array_pop_impl(self, i);
104
105exit:
106 return return_value;
107}
108
109PyDoc_STRVAR(array_array_extend__doc__,
110"extend($self, bb, /)\n"
111"--\n"
112"\n"
113"Append items to the end of the array.");
114
115#define ARRAY_ARRAY_EXTEND_METHODDEF \
116 {"extend", (PyCFunction)array_array_extend, METH_O, array_array_extend__doc__},
117
118PyDoc_STRVAR(array_array_insert__doc__,
119"insert($self, i, v, /)\n"
120"--\n"
121"\n"
122"Insert a new item v into the array before position i.");
123
124#define ARRAY_ARRAY_INSERT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200125 {"insert", (PyCFunction)(void(*)(void))array_array_insert, METH_FASTCALL, array_array_insert__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400126
127static PyObject *
128array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v);
129
130static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200131array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400132{
133 PyObject *return_value = NULL;
134 Py_ssize_t i;
135 PyObject *v;
136
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200137 if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100138 goto exit;
139 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200140 if (PyFloat_Check(args[0])) {
141 PyErr_SetString(PyExc_TypeError,
142 "integer argument expected, got float" );
143 goto exit;
144 }
145 {
146 Py_ssize_t ival = -1;
147 PyObject *iobj = PyNumber_Index(args[0]);
148 if (iobj != NULL) {
149 ival = PyLong_AsSsize_t(iobj);
150 Py_DECREF(iobj);
151 }
152 if (ival == -1 && PyErr_Occurred()) {
153 goto exit;
154 }
155 i = ival;
156 }
157 v = args[1];
Brett Cannon1eb32c22014-10-10 16:26:45 -0400158 return_value = array_array_insert_impl(self, i, v);
159
160exit:
161 return return_value;
162}
163
164PyDoc_STRVAR(array_array_buffer_info__doc__,
165"buffer_info($self, /)\n"
166"--\n"
167"\n"
168"Return a tuple (address, length) giving the current memory address and the length in items of the buffer used to hold array\'s contents.\n"
169"\n"
170"The length should be multiplied by the itemsize attribute to calculate\n"
171"the buffer length in bytes.");
172
173#define ARRAY_ARRAY_BUFFER_INFO_METHODDEF \
174 {"buffer_info", (PyCFunction)array_array_buffer_info, METH_NOARGS, array_array_buffer_info__doc__},
175
176static PyObject *
177array_array_buffer_info_impl(arrayobject *self);
178
179static PyObject *
180array_array_buffer_info(arrayobject *self, PyObject *Py_UNUSED(ignored))
181{
182 return array_array_buffer_info_impl(self);
183}
184
185PyDoc_STRVAR(array_array_append__doc__,
186"append($self, v, /)\n"
187"--\n"
188"\n"
189"Append new value v to the end of the array.");
190
191#define ARRAY_ARRAY_APPEND_METHODDEF \
192 {"append", (PyCFunction)array_array_append, METH_O, array_array_append__doc__},
193
194PyDoc_STRVAR(array_array_byteswap__doc__,
195"byteswap($self, /)\n"
196"--\n"
197"\n"
198"Byteswap all items of the array.\n"
199"\n"
200"If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is\n"
201"raised.");
202
203#define ARRAY_ARRAY_BYTESWAP_METHODDEF \
204 {"byteswap", (PyCFunction)array_array_byteswap, METH_NOARGS, array_array_byteswap__doc__},
205
206static PyObject *
207array_array_byteswap_impl(arrayobject *self);
208
209static PyObject *
210array_array_byteswap(arrayobject *self, PyObject *Py_UNUSED(ignored))
211{
212 return array_array_byteswap_impl(self);
213}
214
215PyDoc_STRVAR(array_array_reverse__doc__,
216"reverse($self, /)\n"
217"--\n"
218"\n"
219"Reverse the order of the items in the array.");
220
221#define ARRAY_ARRAY_REVERSE_METHODDEF \
222 {"reverse", (PyCFunction)array_array_reverse, METH_NOARGS, array_array_reverse__doc__},
223
224static PyObject *
225array_array_reverse_impl(arrayobject *self);
226
227static PyObject *
228array_array_reverse(arrayobject *self, PyObject *Py_UNUSED(ignored))
229{
230 return array_array_reverse_impl(self);
231}
232
233PyDoc_STRVAR(array_array_fromfile__doc__,
234"fromfile($self, f, n, /)\n"
235"--\n"
236"\n"
237"Read n objects from the file object f and append them to the end of the array.");
238
239#define ARRAY_ARRAY_FROMFILE_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200240 {"fromfile", (PyCFunction)(void(*)(void))array_array_fromfile, METH_FASTCALL, array_array_fromfile__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400241
242static PyObject *
243array_array_fromfile_impl(arrayobject *self, PyObject *f, Py_ssize_t n);
244
245static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200246array_array_fromfile(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400247{
248 PyObject *return_value = NULL;
249 PyObject *f;
250 Py_ssize_t n;
251
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200252 if (!_PyArg_CheckPositional("fromfile", nargs, 2, 2)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100253 goto exit;
254 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200255 f = args[0];
256 if (PyFloat_Check(args[1])) {
257 PyErr_SetString(PyExc_TypeError,
258 "integer argument expected, got float" );
259 goto exit;
260 }
261 {
262 Py_ssize_t ival = -1;
263 PyObject *iobj = PyNumber_Index(args[1]);
264 if (iobj != NULL) {
265 ival = PyLong_AsSsize_t(iobj);
266 Py_DECREF(iobj);
267 }
268 if (ival == -1 && PyErr_Occurred()) {
269 goto exit;
270 }
271 n = ival;
272 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400273 return_value = array_array_fromfile_impl(self, f, n);
274
275exit:
276 return return_value;
277}
278
279PyDoc_STRVAR(array_array_tofile__doc__,
280"tofile($self, f, /)\n"
281"--\n"
282"\n"
283"Write all items (as machine values) to the file object f.");
284
285#define ARRAY_ARRAY_TOFILE_METHODDEF \
286 {"tofile", (PyCFunction)array_array_tofile, METH_O, array_array_tofile__doc__},
287
288PyDoc_STRVAR(array_array_fromlist__doc__,
289"fromlist($self, list, /)\n"
290"--\n"
291"\n"
292"Append items to array from list.");
293
294#define ARRAY_ARRAY_FROMLIST_METHODDEF \
295 {"fromlist", (PyCFunction)array_array_fromlist, METH_O, array_array_fromlist__doc__},
296
297PyDoc_STRVAR(array_array_tolist__doc__,
298"tolist($self, /)\n"
299"--\n"
300"\n"
301"Convert array to an ordinary list with the same items.");
302
303#define ARRAY_ARRAY_TOLIST_METHODDEF \
304 {"tolist", (PyCFunction)array_array_tolist, METH_NOARGS, array_array_tolist__doc__},
305
306static PyObject *
307array_array_tolist_impl(arrayobject *self);
308
309static PyObject *
310array_array_tolist(arrayobject *self, PyObject *Py_UNUSED(ignored))
311{
312 return array_array_tolist_impl(self);
313}
314
315PyDoc_STRVAR(array_array_fromstring__doc__,
316"fromstring($self, buffer, /)\n"
317"--\n"
318"\n"
319"Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).\n"
320"\n"
321"This method is deprecated. Use frombytes instead.");
322
323#define ARRAY_ARRAY_FROMSTRING_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300324 {"fromstring", (PyCFunction)array_array_fromstring, METH_O, array_array_fromstring__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400325
326static PyObject *
327array_array_fromstring_impl(arrayobject *self, Py_buffer *buffer);
328
329static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300330array_array_fromstring(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400331{
332 PyObject *return_value = NULL;
333 Py_buffer buffer = {NULL, NULL};
334
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200335 if (PyUnicode_Check(arg)) {
336 Py_ssize_t len;
337 const char *ptr = PyUnicode_AsUTF8AndSize(arg, &len);
338 if (ptr == NULL) {
339 goto exit;
340 }
341 PyBuffer_FillInfo(&buffer, arg, (void *)ptr, len, 1, 0);
342 }
343 else { /* any bytes-like object */
344 if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
345 goto exit;
346 }
347 if (!PyBuffer_IsContiguous(&buffer, 'C')) {
Rémi Lapeyre4901fe22019-08-29 16:49:08 +0200348 _PyArg_BadArgument("fromstring", "argument", "contiguous buffer", arg);
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200349 goto exit;
350 }
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300351 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400352 return_value = array_array_fromstring_impl(self, &buffer);
353
354exit:
355 /* Cleanup for buffer */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300356 if (buffer.obj) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400357 PyBuffer_Release(&buffer);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300358 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400359
360 return return_value;
361}
362
363PyDoc_STRVAR(array_array_frombytes__doc__,
364"frombytes($self, buffer, /)\n"
365"--\n"
366"\n"
367"Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).");
368
369#define ARRAY_ARRAY_FROMBYTES_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300370 {"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400371
372static PyObject *
373array_array_frombytes_impl(arrayobject *self, Py_buffer *buffer);
374
375static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300376array_array_frombytes(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400377{
378 PyObject *return_value = NULL;
379 Py_buffer buffer = {NULL, NULL};
380
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200381 if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
382 goto exit;
383 }
384 if (!PyBuffer_IsContiguous(&buffer, 'C')) {
Rémi Lapeyre4901fe22019-08-29 16:49:08 +0200385 _PyArg_BadArgument("frombytes", "argument", "contiguous buffer", arg);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400386 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300387 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400388 return_value = array_array_frombytes_impl(self, &buffer);
389
390exit:
391 /* Cleanup for buffer */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300392 if (buffer.obj) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400393 PyBuffer_Release(&buffer);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300394 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400395
396 return return_value;
397}
398
399PyDoc_STRVAR(array_array_tobytes__doc__,
400"tobytes($self, /)\n"
401"--\n"
402"\n"
403"Convert the array to an array of machine values and return the bytes representation.");
404
405#define ARRAY_ARRAY_TOBYTES_METHODDEF \
406 {"tobytes", (PyCFunction)array_array_tobytes, METH_NOARGS, array_array_tobytes__doc__},
407
408static PyObject *
409array_array_tobytes_impl(arrayobject *self);
410
411static PyObject *
412array_array_tobytes(arrayobject *self, PyObject *Py_UNUSED(ignored))
413{
414 return array_array_tobytes_impl(self);
415}
416
417PyDoc_STRVAR(array_array_tostring__doc__,
418"tostring($self, /)\n"
419"--\n"
420"\n"
421"Convert the array to an array of machine values and return the bytes representation.\n"
422"\n"
423"This method is deprecated. Use tobytes instead.");
424
425#define ARRAY_ARRAY_TOSTRING_METHODDEF \
426 {"tostring", (PyCFunction)array_array_tostring, METH_NOARGS, array_array_tostring__doc__},
427
428static PyObject *
429array_array_tostring_impl(arrayobject *self);
430
431static PyObject *
432array_array_tostring(arrayobject *self, PyObject *Py_UNUSED(ignored))
433{
434 return array_array_tostring_impl(self);
435}
436
437PyDoc_STRVAR(array_array_fromunicode__doc__,
438"fromunicode($self, ustr, /)\n"
439"--\n"
440"\n"
441"Extends this array with data from the unicode string ustr.\n"
442"\n"
443"The array must be a unicode type array; otherwise a ValueError is raised.\n"
444"Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of\n"
445"some other type.");
446
447#define ARRAY_ARRAY_FROMUNICODE_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300448 {"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400449
450static PyObject *
Serhiy Storchakaafb3e712018-12-14 11:19:51 +0200451array_array_fromunicode_impl(arrayobject *self, const Py_UNICODE *ustr,
Larry Hastings89964c42015-04-14 18:07:59 -0400452 Py_ssize_clean_t ustr_length);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400453
454static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300455array_array_fromunicode(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400456{
457 PyObject *return_value = NULL;
Serhiy Storchakaafb3e712018-12-14 11:19:51 +0200458 const Py_UNICODE *ustr;
Brett Cannon1eb32c22014-10-10 16:26:45 -0400459 Py_ssize_clean_t ustr_length;
460
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300461 if (!PyArg_Parse(arg, "u#:fromunicode", &ustr, &ustr_length)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400462 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300463 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400464 return_value = array_array_fromunicode_impl(self, ustr, ustr_length);
465
466exit:
467 return return_value;
468}
469
470PyDoc_STRVAR(array_array_tounicode__doc__,
471"tounicode($self, /)\n"
472"--\n"
473"\n"
474"Extends this array with data from the unicode string ustr.\n"
475"\n"
476"Convert the array to a unicode string. The array must be a unicode type array;\n"
477"otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a\n"
478"unicode string from an array of some other type.");
479
480#define ARRAY_ARRAY_TOUNICODE_METHODDEF \
481 {"tounicode", (PyCFunction)array_array_tounicode, METH_NOARGS, array_array_tounicode__doc__},
482
483static PyObject *
484array_array_tounicode_impl(arrayobject *self);
485
486static PyObject *
487array_array_tounicode(arrayobject *self, PyObject *Py_UNUSED(ignored))
488{
489 return array_array_tounicode_impl(self);
490}
491
492PyDoc_STRVAR(array_array___sizeof____doc__,
493"__sizeof__($self, /)\n"
494"--\n"
495"\n"
496"Size of the array in memory, in bytes.");
497
498#define ARRAY_ARRAY___SIZEOF___METHODDEF \
499 {"__sizeof__", (PyCFunction)array_array___sizeof__, METH_NOARGS, array_array___sizeof____doc__},
500
501static PyObject *
502array_array___sizeof___impl(arrayobject *self);
503
504static PyObject *
505array_array___sizeof__(arrayobject *self, PyObject *Py_UNUSED(ignored))
506{
507 return array_array___sizeof___impl(self);
508}
509
510PyDoc_STRVAR(array__array_reconstructor__doc__,
511"_array_reconstructor($module, arraytype, typecode, mformat_code, items,\n"
512" /)\n"
513"--\n"
514"\n"
515"Internal. Used for pickling support.");
516
517#define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200518 {"_array_reconstructor", (PyCFunction)(void(*)(void))array__array_reconstructor, METH_FASTCALL, array__array_reconstructor__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400519
520static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300521array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype,
Larry Hastings89964c42015-04-14 18:07:59 -0400522 int typecode,
523 enum machine_format_code mformat_code,
524 PyObject *items);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400525
526static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200527array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400528{
529 PyObject *return_value = NULL;
530 PyTypeObject *arraytype;
531 int typecode;
Larry Hastingsdfbeb162014-10-13 10:39:41 +0100532 enum machine_format_code mformat_code;
Brett Cannon1eb32c22014-10-10 16:26:45 -0400533 PyObject *items;
534
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200535 if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100536 goto exit;
537 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200538 arraytype = (PyTypeObject *)args[0];
539 if (!PyUnicode_Check(args[1])) {
Rémi Lapeyre4901fe22019-08-29 16:49:08 +0200540 _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200541 goto exit;
542 }
543 if (PyUnicode_READY(args[1])) {
544 goto exit;
545 }
546 if (PyUnicode_GET_LENGTH(args[1]) != 1) {
Rémi Lapeyre4901fe22019-08-29 16:49:08 +0200547 _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200548 goto exit;
549 }
550 typecode = PyUnicode_READ_CHAR(args[1], 0);
551 if (PyFloat_Check(args[2])) {
552 PyErr_SetString(PyExc_TypeError,
553 "integer argument expected, got float" );
554 goto exit;
555 }
556 mformat_code = _PyLong_AsInt(args[2]);
557 if (mformat_code == -1 && PyErr_Occurred()) {
558 goto exit;
559 }
560 items = args[3];
Brett Cannon1eb32c22014-10-10 16:26:45 -0400561 return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
562
563exit:
564 return return_value;
565}
566
567PyDoc_STRVAR(array_array___reduce_ex____doc__,
568"__reduce_ex__($self, value, /)\n"
569"--\n"
570"\n"
571"Return state information for pickling.");
572
573#define ARRAY_ARRAY___REDUCE_EX___METHODDEF \
574 {"__reduce_ex__", (PyCFunction)array_array___reduce_ex__, METH_O, array_array___reduce_ex____doc__},
575
576PyDoc_STRVAR(array_arrayiterator___reduce____doc__,
577"__reduce__($self, /)\n"
578"--\n"
579"\n"
580"Return state information for pickling.");
581
582#define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF \
583 {"__reduce__", (PyCFunction)array_arrayiterator___reduce__, METH_NOARGS, array_arrayiterator___reduce____doc__},
584
585static PyObject *
586array_arrayiterator___reduce___impl(arrayiterobject *self);
587
588static PyObject *
589array_arrayiterator___reduce__(arrayiterobject *self, PyObject *Py_UNUSED(ignored))
590{
591 return array_arrayiterator___reduce___impl(self);
592}
593
594PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
595"__setstate__($self, state, /)\n"
596"--\n"
597"\n"
598"Set state information for unpickling.");
599
600#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
601 {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
Rémi Lapeyre4901fe22019-08-29 16:49:08 +0200602/*[clinic end generated code: output=6aa421571e2c0756 input=a9049054013a1b77]*/