/src/cpython/Modules/_io/clinic/textio.c.h
Line | Count | Source |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
6 | | # include "pycore_gc.h" // PyGC_Head |
7 | | # include "pycore_runtime.h" // _Py_SINGLETON() |
8 | | #endif |
9 | | #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() |
10 | | #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() |
11 | | #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
12 | | |
13 | | PyDoc_STRVAR(_io__TextIOBase_detach__doc__, |
14 | | "detach($self, /)\n" |
15 | | "--\n" |
16 | | "\n" |
17 | | "Separate the underlying buffer from the TextIOBase and return it.\n" |
18 | | "\n" |
19 | | "After the underlying buffer has been detached, the TextIO is in\n" |
20 | | "an unusable state."); |
21 | | |
22 | | #define _IO__TEXTIOBASE_DETACH_METHODDEF \ |
23 | | {"detach", _PyCFunction_CAST(_io__TextIOBase_detach), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_detach__doc__}, |
24 | | |
25 | | static PyObject * |
26 | | _io__TextIOBase_detach_impl(PyObject *self, PyTypeObject *cls); |
27 | | |
28 | | static PyObject * |
29 | | _io__TextIOBase_detach(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
30 | 0 | { |
31 | 0 | if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
32 | 0 | PyErr_SetString(PyExc_TypeError, "detach() takes no arguments"); |
33 | 0 | return NULL; |
34 | 0 | } |
35 | 0 | return _io__TextIOBase_detach_impl(self, cls); |
36 | 0 | } |
37 | | |
38 | | PyDoc_STRVAR(_io__TextIOBase_read__doc__, |
39 | | "read($self, size=-1, /)\n" |
40 | | "--\n" |
41 | | "\n" |
42 | | "Read at most size characters from stream.\n" |
43 | | "\n" |
44 | | "Read from underlying buffer until we have size characters or we hit\n" |
45 | | "EOF. If size is negative or omitted, read until EOF."); |
46 | | |
47 | | #define _IO__TEXTIOBASE_READ_METHODDEF \ |
48 | | {"read", _PyCFunction_CAST(_io__TextIOBase_read), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_read__doc__}, |
49 | | |
50 | | static PyObject * |
51 | | _io__TextIOBase_read_impl(PyObject *self, PyTypeObject *cls, |
52 | | int Py_UNUSED(size)); |
53 | | |
54 | | static PyObject * |
55 | | _io__TextIOBase_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
56 | 0 | { |
57 | 0 | PyObject *return_value = NULL; |
58 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
59 | 0 | # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
60 | | #else |
61 | | # define KWTUPLE NULL |
62 | | #endif |
63 | |
|
64 | 0 | static const char * const _keywords[] = {"", NULL}; |
65 | 0 | static _PyArg_Parser _parser = { |
66 | 0 | .keywords = _keywords, |
67 | 0 | .fname = "read", |
68 | 0 | .kwtuple = KWTUPLE, |
69 | 0 | }; |
70 | 0 | #undef KWTUPLE |
71 | 0 | PyObject *argsbuf[1]; |
72 | 0 | int size = -1; |
73 | |
|
74 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
75 | 0 | /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
76 | 0 | if (!args) { |
77 | 0 | goto exit; |
78 | 0 | } |
79 | 0 | if (nargs < 1) { |
80 | 0 | goto skip_optional_posonly; |
81 | 0 | } |
82 | 0 | size = PyLong_AsInt(args[0]); |
83 | 0 | if (size == -1 && PyErr_Occurred()) { |
84 | 0 | goto exit; |
85 | 0 | } |
86 | 0 | skip_optional_posonly: |
87 | 0 | return_value = _io__TextIOBase_read_impl(self, cls, size); |
88 | |
|
89 | 0 | exit: |
90 | 0 | return return_value; |
91 | 0 | } |
92 | | |
93 | | PyDoc_STRVAR(_io__TextIOBase_readline__doc__, |
94 | | "readline($self, size=-1, /)\n" |
95 | | "--\n" |
96 | | "\n" |
97 | | "Read until newline or EOF.\n" |
98 | | "\n" |
99 | | "Return an empty string if EOF is hit immediately.\n" |
100 | | "If size is specified, at most size characters will be read."); |
101 | | |
102 | | #define _IO__TEXTIOBASE_READLINE_METHODDEF \ |
103 | | {"readline", _PyCFunction_CAST(_io__TextIOBase_readline), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_readline__doc__}, |
104 | | |
105 | | static PyObject * |
106 | | _io__TextIOBase_readline_impl(PyObject *self, PyTypeObject *cls, |
107 | | int Py_UNUSED(size)); |
108 | | |
109 | | static PyObject * |
110 | | _io__TextIOBase_readline(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
111 | 0 | { |
112 | 0 | PyObject *return_value = NULL; |
113 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
114 | 0 | # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
115 | | #else |
116 | | # define KWTUPLE NULL |
117 | | #endif |
118 | |
|
119 | 0 | static const char * const _keywords[] = {"", NULL}; |
120 | 0 | static _PyArg_Parser _parser = { |
121 | 0 | .keywords = _keywords, |
122 | 0 | .fname = "readline", |
123 | 0 | .kwtuple = KWTUPLE, |
124 | 0 | }; |
125 | 0 | #undef KWTUPLE |
126 | 0 | PyObject *argsbuf[1]; |
127 | 0 | int size = -1; |
128 | |
|
129 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
130 | 0 | /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
131 | 0 | if (!args) { |
132 | 0 | goto exit; |
133 | 0 | } |
134 | 0 | if (nargs < 1) { |
135 | 0 | goto skip_optional_posonly; |
136 | 0 | } |
137 | 0 | size = PyLong_AsInt(args[0]); |
138 | 0 | if (size == -1 && PyErr_Occurred()) { |
139 | 0 | goto exit; |
140 | 0 | } |
141 | 0 | skip_optional_posonly: |
142 | 0 | return_value = _io__TextIOBase_readline_impl(self, cls, size); |
143 | |
|
144 | 0 | exit: |
145 | 0 | return return_value; |
146 | 0 | } |
147 | | |
148 | | PyDoc_STRVAR(_io__TextIOBase_write__doc__, |
149 | | "write($self, s, /)\n" |
150 | | "--\n" |
151 | | "\n" |
152 | | "Write string s to stream.\n" |
153 | | "\n" |
154 | | "Return the number of characters written\n" |
155 | | "(which is always equal to the length of the string)."); |
156 | | |
157 | | #define _IO__TEXTIOBASE_WRITE_METHODDEF \ |
158 | | {"write", _PyCFunction_CAST(_io__TextIOBase_write), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _io__TextIOBase_write__doc__}, |
159 | | |
160 | | static PyObject * |
161 | | _io__TextIOBase_write_impl(PyObject *self, PyTypeObject *cls, |
162 | | const char *Py_UNUSED(s)); |
163 | | |
164 | | static PyObject * |
165 | | _io__TextIOBase_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
166 | 0 | { |
167 | 0 | PyObject *return_value = NULL; |
168 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
169 | 0 | # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
170 | | #else |
171 | | # define KWTUPLE NULL |
172 | | #endif |
173 | |
|
174 | 0 | static const char * const _keywords[] = {"", NULL}; |
175 | 0 | static _PyArg_Parser _parser = { |
176 | 0 | .keywords = _keywords, |
177 | 0 | .fname = "write", |
178 | 0 | .kwtuple = KWTUPLE, |
179 | 0 | }; |
180 | 0 | #undef KWTUPLE |
181 | 0 | PyObject *argsbuf[1]; |
182 | 0 | const char *s; |
183 | |
|
184 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
185 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
186 | 0 | if (!args) { |
187 | 0 | goto exit; |
188 | 0 | } |
189 | 0 | if (!PyUnicode_Check(args[0])) { |
190 | 0 | _PyArg_BadArgument("write", "argument 1", "str", args[0]); |
191 | 0 | goto exit; |
192 | 0 | } |
193 | 0 | Py_ssize_t s_length; |
194 | 0 | s = PyUnicode_AsUTF8AndSize(args[0], &s_length); |
195 | 0 | if (s == NULL) { |
196 | 0 | goto exit; |
197 | 0 | } |
198 | 0 | if (strlen(s) != (size_t)s_length) { |
199 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
200 | 0 | goto exit; |
201 | 0 | } |
202 | 0 | return_value = _io__TextIOBase_write_impl(self, cls, s); |
203 | |
|
204 | 0 | exit: |
205 | 0 | return return_value; |
206 | 0 | } |
207 | | |
208 | | PyDoc_STRVAR(_io__TextIOBase_encoding__doc__, |
209 | | "Encoding of the text stream.\n" |
210 | | "\n" |
211 | | "Subclasses should override."); |
212 | | #if defined(_io__TextIOBase_encoding_DOCSTR) |
213 | | # undef _io__TextIOBase_encoding_DOCSTR |
214 | | #endif |
215 | | #define _io__TextIOBase_encoding_DOCSTR _io__TextIOBase_encoding__doc__ |
216 | | |
217 | | #if !defined(_io__TextIOBase_encoding_DOCSTR) |
218 | | # define _io__TextIOBase_encoding_DOCSTR NULL |
219 | | #endif |
220 | | #if defined(_IO__TEXTIOBASE_ENCODING_GETSETDEF) |
221 | | # undef _IO__TEXTIOBASE_ENCODING_GETSETDEF |
222 | | # define _IO__TEXTIOBASE_ENCODING_GETSETDEF {"encoding", (getter)_io__TextIOBase_encoding_get, (setter)_io__TextIOBase_encoding_set, _io__TextIOBase_encoding_DOCSTR}, |
223 | | #else |
224 | | # define _IO__TEXTIOBASE_ENCODING_GETSETDEF {"encoding", (getter)_io__TextIOBase_encoding_get, NULL, _io__TextIOBase_encoding_DOCSTR}, |
225 | | #endif |
226 | | |
227 | | static PyObject * |
228 | | _io__TextIOBase_encoding_get_impl(PyObject *self); |
229 | | |
230 | | static PyObject * |
231 | | _io__TextIOBase_encoding_get(PyObject *self, void *Py_UNUSED(context)) |
232 | 0 | { |
233 | 0 | return _io__TextIOBase_encoding_get_impl(self); |
234 | 0 | } |
235 | | |
236 | | PyDoc_STRVAR(_io__TextIOBase_newlines__doc__, |
237 | | "Line endings translated so far.\n" |
238 | | "\n" |
239 | | "Only line endings translated during reading are considered.\n" |
240 | | "\n" |
241 | | "Subclasses should override."); |
242 | | #if defined(_io__TextIOBase_newlines_DOCSTR) |
243 | | # undef _io__TextIOBase_newlines_DOCSTR |
244 | | #endif |
245 | | #define _io__TextIOBase_newlines_DOCSTR _io__TextIOBase_newlines__doc__ |
246 | | |
247 | | #if !defined(_io__TextIOBase_newlines_DOCSTR) |
248 | | # define _io__TextIOBase_newlines_DOCSTR NULL |
249 | | #endif |
250 | | #if defined(_IO__TEXTIOBASE_NEWLINES_GETSETDEF) |
251 | | # undef _IO__TEXTIOBASE_NEWLINES_GETSETDEF |
252 | | # define _IO__TEXTIOBASE_NEWLINES_GETSETDEF {"newlines", (getter)_io__TextIOBase_newlines_get, (setter)_io__TextIOBase_newlines_set, _io__TextIOBase_newlines_DOCSTR}, |
253 | | #else |
254 | | # define _IO__TEXTIOBASE_NEWLINES_GETSETDEF {"newlines", (getter)_io__TextIOBase_newlines_get, NULL, _io__TextIOBase_newlines_DOCSTR}, |
255 | | #endif |
256 | | |
257 | | static PyObject * |
258 | | _io__TextIOBase_newlines_get_impl(PyObject *self); |
259 | | |
260 | | static PyObject * |
261 | | _io__TextIOBase_newlines_get(PyObject *self, void *Py_UNUSED(context)) |
262 | 0 | { |
263 | 0 | return _io__TextIOBase_newlines_get_impl(self); |
264 | 0 | } |
265 | | |
266 | | PyDoc_STRVAR(_io__TextIOBase_errors__doc__, |
267 | | "The error setting of the decoder or encoder.\n" |
268 | | "\n" |
269 | | "Subclasses should override."); |
270 | | #if defined(_io__TextIOBase_errors_DOCSTR) |
271 | | # undef _io__TextIOBase_errors_DOCSTR |
272 | | #endif |
273 | | #define _io__TextIOBase_errors_DOCSTR _io__TextIOBase_errors__doc__ |
274 | | |
275 | | #if !defined(_io__TextIOBase_errors_DOCSTR) |
276 | | # define _io__TextIOBase_errors_DOCSTR NULL |
277 | | #endif |
278 | | #if defined(_IO__TEXTIOBASE_ERRORS_GETSETDEF) |
279 | | # undef _IO__TEXTIOBASE_ERRORS_GETSETDEF |
280 | | # define _IO__TEXTIOBASE_ERRORS_GETSETDEF {"errors", (getter)_io__TextIOBase_errors_get, (setter)_io__TextIOBase_errors_set, _io__TextIOBase_errors_DOCSTR}, |
281 | | #else |
282 | | # define _IO__TEXTIOBASE_ERRORS_GETSETDEF {"errors", (getter)_io__TextIOBase_errors_get, NULL, _io__TextIOBase_errors_DOCSTR}, |
283 | | #endif |
284 | | |
285 | | static PyObject * |
286 | | _io__TextIOBase_errors_get_impl(PyObject *self); |
287 | | |
288 | | static PyObject * |
289 | | _io__TextIOBase_errors_get(PyObject *self, void *Py_UNUSED(context)) |
290 | 0 | { |
291 | 0 | return _io__TextIOBase_errors_get_impl(self); |
292 | 0 | } |
293 | | |
294 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder___init____doc__, |
295 | | "IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n" |
296 | | "--\n" |
297 | | "\n" |
298 | | "Codec used when reading a file in universal newlines mode.\n" |
299 | | "\n" |
300 | | "It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n" |
301 | | "It also records the types of newlines encountered. When used with\n" |
302 | | "translate=False, it ensures that the newline sequence is returned in\n" |
303 | | "one piece. When used with decoder=None, it expects unicode strings as\n" |
304 | | "decode input and translates newlines without first invoking an external\n" |
305 | | "decoder."); |
306 | | |
307 | | static int |
308 | | _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self, |
309 | | PyObject *decoder, int translate, |
310 | | PyObject *errors); |
311 | | |
312 | | static int |
313 | | _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
314 | 15.8k | { |
315 | 15.8k | int return_value = -1; |
316 | 15.8k | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
317 | | |
318 | 15.8k | #define NUM_KEYWORDS 3 |
319 | 15.8k | static struct { |
320 | 15.8k | PyGC_Head _this_is_not_used; |
321 | 15.8k | PyObject_VAR_HEAD |
322 | 15.8k | Py_hash_t ob_hash; |
323 | 15.8k | PyObject *ob_item[NUM_KEYWORDS]; |
324 | 15.8k | } _kwtuple = { |
325 | 15.8k | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
326 | 15.8k | .ob_hash = -1, |
327 | 15.8k | .ob_item = { &_Py_ID(decoder), &_Py_ID(translate), &_Py_ID(errors), }, |
328 | 15.8k | }; |
329 | 15.8k | #undef NUM_KEYWORDS |
330 | 15.8k | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
331 | | |
332 | | #else // !Py_BUILD_CORE |
333 | | # define KWTUPLE NULL |
334 | | #endif // !Py_BUILD_CORE |
335 | | |
336 | 15.8k | static const char * const _keywords[] = {"decoder", "translate", "errors", NULL}; |
337 | 15.8k | static _PyArg_Parser _parser = { |
338 | 15.8k | .keywords = _keywords, |
339 | 15.8k | .fname = "IncrementalNewlineDecoder", |
340 | 15.8k | .kwtuple = KWTUPLE, |
341 | 15.8k | }; |
342 | 15.8k | #undef KWTUPLE |
343 | 15.8k | PyObject *argsbuf[3]; |
344 | 15.8k | PyObject * const *fastargs; |
345 | 15.8k | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
346 | 15.8k | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; |
347 | 15.8k | PyObject *decoder; |
348 | 15.8k | int translate; |
349 | 15.8k | PyObject *errors = NULL; |
350 | | |
351 | 15.8k | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
352 | 15.8k | /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
353 | 15.8k | if (!fastargs) { |
354 | 0 | goto exit; |
355 | 0 | } |
356 | 15.8k | decoder = fastargs[0]; |
357 | 15.8k | translate = PyObject_IsTrue(fastargs[1]); |
358 | 15.8k | if (translate < 0) { |
359 | 0 | goto exit; |
360 | 0 | } |
361 | 15.8k | if (!noptargs) { |
362 | 15.8k | goto skip_optional_pos; |
363 | 15.8k | } |
364 | 0 | errors = fastargs[2]; |
365 | 15.8k | skip_optional_pos: |
366 | 15.8k | return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors); |
367 | | |
368 | 15.8k | exit: |
369 | 15.8k | return return_value; |
370 | 15.8k | } |
371 | | |
372 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__, |
373 | | "decode($self, /, input, final=False)\n" |
374 | | "--\n" |
375 | | "\n"); |
376 | | |
377 | | #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF \ |
378 | | {"decode", _PyCFunction_CAST(_io_IncrementalNewlineDecoder_decode), METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__}, |
379 | | |
380 | | static PyObject * |
381 | | _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self, |
382 | | PyObject *input, int final); |
383 | | |
384 | | static PyObject * |
385 | | _io_IncrementalNewlineDecoder_decode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
386 | 0 | { |
387 | 0 | PyObject *return_value = NULL; |
388 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
389 | |
|
390 | 0 | #define NUM_KEYWORDS 2 |
391 | 0 | static struct { |
392 | 0 | PyGC_Head _this_is_not_used; |
393 | 0 | PyObject_VAR_HEAD |
394 | 0 | Py_hash_t ob_hash; |
395 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
396 | 0 | } _kwtuple = { |
397 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
398 | 0 | .ob_hash = -1, |
399 | 0 | .ob_item = { &_Py_ID(input), &_Py_ID(final), }, |
400 | 0 | }; |
401 | 0 | #undef NUM_KEYWORDS |
402 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
403 | |
|
404 | | #else // !Py_BUILD_CORE |
405 | | # define KWTUPLE NULL |
406 | | #endif // !Py_BUILD_CORE |
407 | |
|
408 | 0 | static const char * const _keywords[] = {"input", "final", NULL}; |
409 | 0 | static _PyArg_Parser _parser = { |
410 | 0 | .keywords = _keywords, |
411 | 0 | .fname = "decode", |
412 | 0 | .kwtuple = KWTUPLE, |
413 | 0 | }; |
414 | 0 | #undef KWTUPLE |
415 | 0 | PyObject *argsbuf[2]; |
416 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
417 | 0 | PyObject *input; |
418 | 0 | int final = 0; |
419 | |
|
420 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
421 | 0 | /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
422 | 0 | if (!args) { |
423 | 0 | goto exit; |
424 | 0 | } |
425 | 0 | input = args[0]; |
426 | 0 | if (!noptargs) { |
427 | 0 | goto skip_optional_pos; |
428 | 0 | } |
429 | 0 | final = PyObject_IsTrue(args[1]); |
430 | 0 | if (final < 0) { |
431 | 0 | goto exit; |
432 | 0 | } |
433 | 0 | skip_optional_pos: |
434 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
435 | 0 | return_value = _io_IncrementalNewlineDecoder_decode_impl((nldecoder_object *)self, input, final); |
436 | 0 | Py_END_CRITICAL_SECTION(); |
437 | |
|
438 | 0 | exit: |
439 | 0 | return return_value; |
440 | 0 | } |
441 | | |
442 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__, |
443 | | "getstate($self, /)\n" |
444 | | "--\n" |
445 | | "\n"); |
446 | | |
447 | | #define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF \ |
448 | | {"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__}, |
449 | | |
450 | | static PyObject * |
451 | | _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self); |
452 | | |
453 | | static PyObject * |
454 | | _io_IncrementalNewlineDecoder_getstate(PyObject *self, PyObject *Py_UNUSED(ignored)) |
455 | 0 | { |
456 | 0 | PyObject *return_value = NULL; |
457 | |
|
458 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
459 | 0 | return_value = _io_IncrementalNewlineDecoder_getstate_impl((nldecoder_object *)self); |
460 | 0 | Py_END_CRITICAL_SECTION(); |
461 | |
|
462 | 0 | return return_value; |
463 | 0 | } |
464 | | |
465 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__, |
466 | | "setstate($self, state, /)\n" |
467 | | "--\n" |
468 | | "\n"); |
469 | | |
470 | | #define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF \ |
471 | | {"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__}, |
472 | | |
473 | | static PyObject * |
474 | | _io_IncrementalNewlineDecoder_setstate_impl(nldecoder_object *self, |
475 | | PyObject *state); |
476 | | |
477 | | static PyObject * |
478 | | _io_IncrementalNewlineDecoder_setstate(PyObject *self, PyObject *state) |
479 | 0 | { |
480 | 0 | PyObject *return_value = NULL; |
481 | |
|
482 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
483 | 0 | return_value = _io_IncrementalNewlineDecoder_setstate_impl((nldecoder_object *)self, state); |
484 | 0 | Py_END_CRITICAL_SECTION(); |
485 | |
|
486 | 0 | return return_value; |
487 | 0 | } |
488 | | |
489 | | PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__, |
490 | | "reset($self, /)\n" |
491 | | "--\n" |
492 | | "\n"); |
493 | | |
494 | | #define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF \ |
495 | | {"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__}, |
496 | | |
497 | | static PyObject * |
498 | | _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self); |
499 | | |
500 | | static PyObject * |
501 | | _io_IncrementalNewlineDecoder_reset(PyObject *self, PyObject *Py_UNUSED(ignored)) |
502 | 0 | { |
503 | 0 | PyObject *return_value = NULL; |
504 | |
|
505 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
506 | 0 | return_value = _io_IncrementalNewlineDecoder_reset_impl((nldecoder_object *)self); |
507 | 0 | Py_END_CRITICAL_SECTION(); |
508 | |
|
509 | 0 | return return_value; |
510 | 0 | } |
511 | | |
512 | | PyDoc_STRVAR(_io_TextIOWrapper___init____doc__, |
513 | | "TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n" |
514 | | " line_buffering=False, write_through=False)\n" |
515 | | "--\n" |
516 | | "\n" |
517 | | "Character and line based layer over a BufferedIOBase object, buffer.\n" |
518 | | "\n" |
519 | | "encoding gives the name of the encoding that the stream will be\n" |
520 | | "decoded or encoded with. It defaults to locale.getencoding().\n" |
521 | | "\n" |
522 | | "errors determines the strictness of encoding and decoding (see\n" |
523 | | "help(codecs.Codec) or the documentation for codecs.register) and\n" |
524 | | "defaults to \"strict\".\n" |
525 | | "\n" |
526 | | "newline controls how line endings are handled. It can be None, \'\',\n" |
527 | | "\'\\n\', \'\\r\', and \'\\r\\n\'. It works as follows:\n" |
528 | | "\n" |
529 | | "* On input, if newline is None, universal newlines mode is\n" |
530 | | " enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n" |
531 | | " these are translated into \'\\n\' before being returned to the\n" |
532 | | " caller. If it is \'\', universal newline mode is enabled, but line\n" |
533 | | " endings are returned to the caller untranslated. If it has any of\n" |
534 | | " the other legal values, input lines are only terminated by the given\n" |
535 | | " string, and the line ending is returned to the caller untranslated.\n" |
536 | | "\n" |
537 | | "* On output, if newline is None, any \'\\n\' characters written are\n" |
538 | | " translated to the system default line separator, os.linesep. If\n" |
539 | | " newline is \'\' or \'\\n\', no translation takes place. If newline is any\n" |
540 | | " of the other legal values, any \'\\n\' characters written are translated\n" |
541 | | " to the given string.\n" |
542 | | "\n" |
543 | | "If line_buffering is True, a call to flush is implied when a call to\n" |
544 | | "write contains a newline character."); |
545 | | |
546 | | static int |
547 | | _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, |
548 | | const char *encoding, PyObject *errors, |
549 | | const char *newline, int line_buffering, |
550 | | int write_through); |
551 | | |
552 | | static int |
553 | | _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
554 | 127 | { |
555 | 127 | int return_value = -1; |
556 | 127 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
557 | | |
558 | 127 | #define NUM_KEYWORDS 6 |
559 | 127 | static struct { |
560 | 127 | PyGC_Head _this_is_not_used; |
561 | 127 | PyObject_VAR_HEAD |
562 | 127 | Py_hash_t ob_hash; |
563 | 127 | PyObject *ob_item[NUM_KEYWORDS]; |
564 | 127 | } _kwtuple = { |
565 | 127 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
566 | 127 | .ob_hash = -1, |
567 | 127 | .ob_item = { &_Py_ID(buffer), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), }, |
568 | 127 | }; |
569 | 127 | #undef NUM_KEYWORDS |
570 | 127 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
571 | | |
572 | | #else // !Py_BUILD_CORE |
573 | | # define KWTUPLE NULL |
574 | | #endif // !Py_BUILD_CORE |
575 | | |
576 | 127 | static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL}; |
577 | 127 | static _PyArg_Parser _parser = { |
578 | 127 | .keywords = _keywords, |
579 | 127 | .fname = "TextIOWrapper", |
580 | 127 | .kwtuple = KWTUPLE, |
581 | 127 | }; |
582 | 127 | #undef KWTUPLE |
583 | 127 | PyObject *argsbuf[6]; |
584 | 127 | PyObject * const *fastargs; |
585 | 127 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
586 | 127 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
587 | 127 | PyObject *buffer; |
588 | 127 | const char *encoding = NULL; |
589 | 127 | PyObject *errors = Py_None; |
590 | 127 | const char *newline = NULL; |
591 | 127 | int line_buffering = 0; |
592 | 127 | int write_through = 0; |
593 | | |
594 | 127 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
595 | 127 | /*minpos*/ 1, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
596 | 127 | if (!fastargs) { |
597 | 0 | goto exit; |
598 | 0 | } |
599 | 127 | buffer = fastargs[0]; |
600 | 127 | if (!noptargs) { |
601 | 0 | goto skip_optional_pos; |
602 | 0 | } |
603 | 127 | if (fastargs[1]) { |
604 | 127 | if (fastargs[1] == Py_None) { |
605 | 0 | encoding = NULL; |
606 | 0 | } |
607 | 127 | else if (PyUnicode_Check(fastargs[1])) { |
608 | 127 | Py_ssize_t encoding_length; |
609 | 127 | encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); |
610 | 127 | if (encoding == NULL) { |
611 | 0 | goto exit; |
612 | 0 | } |
613 | 127 | if (strlen(encoding) != (size_t)encoding_length) { |
614 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
615 | 0 | goto exit; |
616 | 0 | } |
617 | 127 | } |
618 | 0 | else { |
619 | 0 | _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]); |
620 | 0 | goto exit; |
621 | 0 | } |
622 | 127 | if (!--noptargs) { |
623 | 0 | goto skip_optional_pos; |
624 | 0 | } |
625 | 127 | } |
626 | 127 | if (fastargs[2]) { |
627 | 117 | errors = fastargs[2]; |
628 | 117 | if (!--noptargs) { |
629 | 0 | goto skip_optional_pos; |
630 | 0 | } |
631 | 117 | } |
632 | 127 | if (fastargs[3]) { |
633 | 117 | if (fastargs[3] == Py_None) { |
634 | 9 | newline = NULL; |
635 | 9 | } |
636 | 108 | else if (PyUnicode_Check(fastargs[3])) { |
637 | 108 | Py_ssize_t newline_length; |
638 | 108 | newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length); |
639 | 108 | if (newline == NULL) { |
640 | 0 | goto exit; |
641 | 0 | } |
642 | 108 | if (strlen(newline) != (size_t)newline_length) { |
643 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
644 | 0 | goto exit; |
645 | 0 | } |
646 | 108 | } |
647 | 0 | else { |
648 | 0 | _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]); |
649 | 0 | goto exit; |
650 | 0 | } |
651 | 117 | if (!--noptargs) { |
652 | 0 | goto skip_optional_pos; |
653 | 0 | } |
654 | 117 | } |
655 | 127 | if (fastargs[4]) { |
656 | 127 | line_buffering = PyObject_IsTrue(fastargs[4]); |
657 | 127 | if (line_buffering < 0) { |
658 | 0 | goto exit; |
659 | 0 | } |
660 | 127 | if (!--noptargs) { |
661 | 19 | goto skip_optional_pos; |
662 | 19 | } |
663 | 127 | } |
664 | 108 | write_through = PyObject_IsTrue(fastargs[5]); |
665 | 108 | if (write_through < 0) { |
666 | 0 | goto exit; |
667 | 0 | } |
668 | 127 | skip_optional_pos: |
669 | 127 | Py_BEGIN_CRITICAL_SECTION(self); |
670 | 127 | return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through); |
671 | 127 | Py_END_CRITICAL_SECTION(); |
672 | | |
673 | 127 | exit: |
674 | 127 | return return_value; |
675 | 127 | } |
676 | | |
677 | | PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__, |
678 | | "reconfigure($self, /, *, encoding=None, errors=None, newline=None,\n" |
679 | | " line_buffering=None, write_through=None)\n" |
680 | | "--\n" |
681 | | "\n" |
682 | | "Reconfigure the text stream with new parameters.\n" |
683 | | "\n" |
684 | | "This also does an implicit stream flush."); |
685 | | |
686 | | #define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF \ |
687 | | {"reconfigure", _PyCFunction_CAST(_io_TextIOWrapper_reconfigure), METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__}, |
688 | | |
689 | | static PyObject * |
690 | | _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding, |
691 | | PyObject *errors, PyObject *newline_obj, |
692 | | PyObject *line_buffering_obj, |
693 | | PyObject *write_through_obj); |
694 | | |
695 | | static PyObject * |
696 | | _io_TextIOWrapper_reconfigure(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
697 | 0 | { |
698 | 0 | PyObject *return_value = NULL; |
699 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
700 | |
|
701 | 0 | #define NUM_KEYWORDS 5 |
702 | 0 | static struct { |
703 | 0 | PyGC_Head _this_is_not_used; |
704 | 0 | PyObject_VAR_HEAD |
705 | 0 | Py_hash_t ob_hash; |
706 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
707 | 0 | } _kwtuple = { |
708 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
709 | 0 | .ob_hash = -1, |
710 | 0 | .ob_item = { &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), }, |
711 | 0 | }; |
712 | 0 | #undef NUM_KEYWORDS |
713 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
714 | |
|
715 | | #else // !Py_BUILD_CORE |
716 | | # define KWTUPLE NULL |
717 | | #endif // !Py_BUILD_CORE |
718 | |
|
719 | 0 | static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL}; |
720 | 0 | static _PyArg_Parser _parser = { |
721 | 0 | .keywords = _keywords, |
722 | 0 | .fname = "reconfigure", |
723 | 0 | .kwtuple = KWTUPLE, |
724 | 0 | }; |
725 | 0 | #undef KWTUPLE |
726 | 0 | PyObject *argsbuf[5]; |
727 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
728 | 0 | PyObject *encoding = Py_None; |
729 | 0 | PyObject *errors = Py_None; |
730 | 0 | PyObject *newline_obj = NULL; |
731 | 0 | PyObject *line_buffering_obj = Py_None; |
732 | 0 | PyObject *write_through_obj = Py_None; |
733 | |
|
734 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
735 | 0 | /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
736 | 0 | if (!args) { |
737 | 0 | goto exit; |
738 | 0 | } |
739 | 0 | if (!noptargs) { |
740 | 0 | goto skip_optional_kwonly; |
741 | 0 | } |
742 | 0 | if (args[0]) { |
743 | 0 | encoding = args[0]; |
744 | 0 | if (!--noptargs) { |
745 | 0 | goto skip_optional_kwonly; |
746 | 0 | } |
747 | 0 | } |
748 | 0 | if (args[1]) { |
749 | 0 | errors = args[1]; |
750 | 0 | if (!--noptargs) { |
751 | 0 | goto skip_optional_kwonly; |
752 | 0 | } |
753 | 0 | } |
754 | 0 | if (args[2]) { |
755 | 0 | newline_obj = args[2]; |
756 | 0 | if (!--noptargs) { |
757 | 0 | goto skip_optional_kwonly; |
758 | 0 | } |
759 | 0 | } |
760 | 0 | if (args[3]) { |
761 | 0 | line_buffering_obj = args[3]; |
762 | 0 | if (!--noptargs) { |
763 | 0 | goto skip_optional_kwonly; |
764 | 0 | } |
765 | 0 | } |
766 | 0 | write_through_obj = args[4]; |
767 | 0 | skip_optional_kwonly: |
768 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
769 | 0 | return_value = _io_TextIOWrapper_reconfigure_impl((textio *)self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj); |
770 | 0 | Py_END_CRITICAL_SECTION(); |
771 | |
|
772 | 0 | exit: |
773 | 0 | return return_value; |
774 | 0 | } |
775 | | |
776 | | PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__, |
777 | | "detach($self, /)\n" |
778 | | "--\n" |
779 | | "\n"); |
780 | | |
781 | | #define _IO_TEXTIOWRAPPER_DETACH_METHODDEF \ |
782 | | {"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__}, |
783 | | |
784 | | static PyObject * |
785 | | _io_TextIOWrapper_detach_impl(textio *self); |
786 | | |
787 | | static PyObject * |
788 | | _io_TextIOWrapper_detach(PyObject *self, PyObject *Py_UNUSED(ignored)) |
789 | 0 | { |
790 | 0 | PyObject *return_value = NULL; |
791 | |
|
792 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
793 | 0 | return_value = _io_TextIOWrapper_detach_impl((textio *)self); |
794 | 0 | Py_END_CRITICAL_SECTION(); |
795 | |
|
796 | 0 | return return_value; |
797 | 0 | } |
798 | | |
799 | | PyDoc_STRVAR(_io_TextIOWrapper_write__doc__, |
800 | | "write($self, text, /)\n" |
801 | | "--\n" |
802 | | "\n"); |
803 | | |
804 | | #define _IO_TEXTIOWRAPPER_WRITE_METHODDEF \ |
805 | | {"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__}, |
806 | | |
807 | | static PyObject * |
808 | | _io_TextIOWrapper_write_impl(textio *self, PyObject *text); |
809 | | |
810 | | static PyObject * |
811 | | _io_TextIOWrapper_write(PyObject *self, PyObject *arg) |
812 | 260k | { |
813 | 260k | PyObject *return_value = NULL; |
814 | 260k | PyObject *text; |
815 | | |
816 | 260k | if (!PyUnicode_Check(arg)) { |
817 | 0 | _PyArg_BadArgument("write", "argument", "str", arg); |
818 | 0 | goto exit; |
819 | 0 | } |
820 | 260k | text = arg; |
821 | 260k | Py_BEGIN_CRITICAL_SECTION(self); |
822 | 260k | return_value = _io_TextIOWrapper_write_impl((textio *)self, text); |
823 | 260k | Py_END_CRITICAL_SECTION(); |
824 | | |
825 | 260k | exit: |
826 | 260k | return return_value; |
827 | 260k | } |
828 | | |
829 | | PyDoc_STRVAR(_io_TextIOWrapper_read__doc__, |
830 | | "read($self, size=-1, /)\n" |
831 | | "--\n" |
832 | | "\n"); |
833 | | |
834 | | #define _IO_TEXTIOWRAPPER_READ_METHODDEF \ |
835 | | {"read", _PyCFunction_CAST(_io_TextIOWrapper_read), METH_FASTCALL, _io_TextIOWrapper_read__doc__}, |
836 | | |
837 | | static PyObject * |
838 | | _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n); |
839 | | |
840 | | static PyObject * |
841 | | _io_TextIOWrapper_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
842 | 8 | { |
843 | 8 | PyObject *return_value = NULL; |
844 | 8 | Py_ssize_t n = -1; |
845 | | |
846 | 8 | if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { |
847 | 0 | goto exit; |
848 | 0 | } |
849 | 8 | if (nargs < 1) { |
850 | 8 | goto skip_optional; |
851 | 8 | } |
852 | 0 | if (!_Py_convert_optional_to_ssize_t(args[0], &n)) { |
853 | 0 | goto exit; |
854 | 0 | } |
855 | 8 | skip_optional: |
856 | 8 | Py_BEGIN_CRITICAL_SECTION(self); |
857 | 8 | return_value = _io_TextIOWrapper_read_impl((textio *)self, n); |
858 | 8 | Py_END_CRITICAL_SECTION(); |
859 | | |
860 | 8 | exit: |
861 | 8 | return return_value; |
862 | 8 | } |
863 | | |
864 | | PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__, |
865 | | "readline($self, size=-1, /)\n" |
866 | | "--\n" |
867 | | "\n"); |
868 | | |
869 | | #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF \ |
870 | | {"readline", _PyCFunction_CAST(_io_TextIOWrapper_readline), METH_FASTCALL, _io_TextIOWrapper_readline__doc__}, |
871 | | |
872 | | static PyObject * |
873 | | _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size); |
874 | | |
875 | | static PyObject * |
876 | | _io_TextIOWrapper_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
877 | 0 | { |
878 | 0 | PyObject *return_value = NULL; |
879 | 0 | Py_ssize_t size = -1; |
880 | |
|
881 | 0 | if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { |
882 | 0 | goto exit; |
883 | 0 | } |
884 | 0 | if (nargs < 1) { |
885 | 0 | goto skip_optional; |
886 | 0 | } |
887 | 0 | { |
888 | 0 | Py_ssize_t ival = -1; |
889 | 0 | PyObject *iobj = _PyNumber_Index(args[0]); |
890 | 0 | if (iobj != NULL) { |
891 | 0 | ival = PyLong_AsSsize_t(iobj); |
892 | 0 | Py_DECREF(iobj); |
893 | 0 | } |
894 | 0 | if (ival == -1 && PyErr_Occurred()) { |
895 | 0 | goto exit; |
896 | 0 | } |
897 | 0 | size = ival; |
898 | 0 | } |
899 | 0 | skip_optional: |
900 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
901 | 0 | return_value = _io_TextIOWrapper_readline_impl((textio *)self, size); |
902 | 0 | Py_END_CRITICAL_SECTION(); |
903 | |
|
904 | 0 | exit: |
905 | 0 | return return_value; |
906 | 0 | } |
907 | | |
908 | | PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__, |
909 | | "seek($self, cookie, whence=os.SEEK_SET, /)\n" |
910 | | "--\n" |
911 | | "\n" |
912 | | "Set the stream position, and return the new stream position.\n" |
913 | | "\n" |
914 | | " cookie\n" |
915 | | " Zero or an opaque number returned by tell().\n" |
916 | | " whence\n" |
917 | | " The relative position to seek from.\n" |
918 | | "\n" |
919 | | "Four operations are supported, given by the following argument\n" |
920 | | "combinations:\n" |
921 | | "\n" |
922 | | "- seek(0, SEEK_SET): Rewind to the start of the stream.\n" |
923 | | "- seek(cookie, SEEK_SET): Restore a previous position;\n" |
924 | | " \'cookie\' must be a number returned by tell().\n" |
925 | | "- seek(0, SEEK_END): Fast-forward to the end of the stream.\n" |
926 | | "- seek(0, SEEK_CUR): Leave the current stream position unchanged.\n" |
927 | | "\n" |
928 | | "Any other argument combinations are invalid,\n" |
929 | | "and may raise exceptions."); |
930 | | |
931 | | #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF \ |
932 | | {"seek", _PyCFunction_CAST(_io_TextIOWrapper_seek), METH_FASTCALL, _io_TextIOWrapper_seek__doc__}, |
933 | | |
934 | | static PyObject * |
935 | | _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence); |
936 | | |
937 | | static PyObject * |
938 | | _io_TextIOWrapper_seek(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
939 | 0 | { |
940 | 0 | PyObject *return_value = NULL; |
941 | 0 | PyObject *cookieObj; |
942 | 0 | int whence = 0; |
943 | |
|
944 | 0 | if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { |
945 | 0 | goto exit; |
946 | 0 | } |
947 | 0 | cookieObj = args[0]; |
948 | 0 | if (nargs < 2) { |
949 | 0 | goto skip_optional; |
950 | 0 | } |
951 | 0 | whence = PyLong_AsInt(args[1]); |
952 | 0 | if (whence == -1 && PyErr_Occurred()) { |
953 | 0 | goto exit; |
954 | 0 | } |
955 | 0 | skip_optional: |
956 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
957 | 0 | return_value = _io_TextIOWrapper_seek_impl((textio *)self, cookieObj, whence); |
958 | 0 | Py_END_CRITICAL_SECTION(); |
959 | |
|
960 | 0 | exit: |
961 | 0 | return return_value; |
962 | 0 | } |
963 | | |
964 | | PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__, |
965 | | "tell($self, /)\n" |
966 | | "--\n" |
967 | | "\n" |
968 | | "Return the stream position as an opaque number.\n" |
969 | | "\n" |
970 | | "The return value of tell() can be given as input to seek(), to\n" |
971 | | "restore a previous stream position."); |
972 | | |
973 | | #define _IO_TEXTIOWRAPPER_TELL_METHODDEF \ |
974 | | {"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__}, |
975 | | |
976 | | static PyObject * |
977 | | _io_TextIOWrapper_tell_impl(textio *self); |
978 | | |
979 | | static PyObject * |
980 | | _io_TextIOWrapper_tell(PyObject *self, PyObject *Py_UNUSED(ignored)) |
981 | 0 | { |
982 | 0 | PyObject *return_value = NULL; |
983 | |
|
984 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
985 | 0 | return_value = _io_TextIOWrapper_tell_impl((textio *)self); |
986 | 0 | Py_END_CRITICAL_SECTION(); |
987 | |
|
988 | 0 | return return_value; |
989 | 0 | } |
990 | | |
991 | | PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__, |
992 | | "truncate($self, pos=None, /)\n" |
993 | | "--\n" |
994 | | "\n"); |
995 | | |
996 | | #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF \ |
997 | | {"truncate", _PyCFunction_CAST(_io_TextIOWrapper_truncate), METH_FASTCALL, _io_TextIOWrapper_truncate__doc__}, |
998 | | |
999 | | static PyObject * |
1000 | | _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos); |
1001 | | |
1002 | | static PyObject * |
1003 | | _io_TextIOWrapper_truncate(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
1004 | 0 | { |
1005 | 0 | PyObject *return_value = NULL; |
1006 | 0 | PyObject *pos = Py_None; |
1007 | |
|
1008 | 0 | if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { |
1009 | 0 | goto exit; |
1010 | 0 | } |
1011 | 0 | if (nargs < 1) { |
1012 | 0 | goto skip_optional; |
1013 | 0 | } |
1014 | 0 | pos = args[0]; |
1015 | 0 | skip_optional: |
1016 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1017 | 0 | return_value = _io_TextIOWrapper_truncate_impl((textio *)self, pos); |
1018 | 0 | Py_END_CRITICAL_SECTION(); |
1019 | |
|
1020 | 0 | exit: |
1021 | 0 | return return_value; |
1022 | 0 | } |
1023 | | |
1024 | | PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__, |
1025 | | "fileno($self, /)\n" |
1026 | | "--\n" |
1027 | | "\n"); |
1028 | | |
1029 | | #define _IO_TEXTIOWRAPPER_FILENO_METHODDEF \ |
1030 | | {"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__}, |
1031 | | |
1032 | | static PyObject * |
1033 | | _io_TextIOWrapper_fileno_impl(textio *self); |
1034 | | |
1035 | | static PyObject * |
1036 | | _io_TextIOWrapper_fileno(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1037 | 0 | { |
1038 | 0 | PyObject *return_value = NULL; |
1039 | |
|
1040 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1041 | 0 | return_value = _io_TextIOWrapper_fileno_impl((textio *)self); |
1042 | 0 | Py_END_CRITICAL_SECTION(); |
1043 | |
|
1044 | 0 | return return_value; |
1045 | 0 | } |
1046 | | |
1047 | | PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__, |
1048 | | "seekable($self, /)\n" |
1049 | | "--\n" |
1050 | | "\n"); |
1051 | | |
1052 | | #define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF \ |
1053 | | {"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__}, |
1054 | | |
1055 | | static PyObject * |
1056 | | _io_TextIOWrapper_seekable_impl(textio *self); |
1057 | | |
1058 | | static PyObject * |
1059 | | _io_TextIOWrapper_seekable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1060 | 0 | { |
1061 | 0 | PyObject *return_value = NULL; |
1062 | |
|
1063 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1064 | 0 | return_value = _io_TextIOWrapper_seekable_impl((textio *)self); |
1065 | 0 | Py_END_CRITICAL_SECTION(); |
1066 | |
|
1067 | 0 | return return_value; |
1068 | 0 | } |
1069 | | |
1070 | | PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__, |
1071 | | "readable($self, /)\n" |
1072 | | "--\n" |
1073 | | "\n"); |
1074 | | |
1075 | | #define _IO_TEXTIOWRAPPER_READABLE_METHODDEF \ |
1076 | | {"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__}, |
1077 | | |
1078 | | static PyObject * |
1079 | | _io_TextIOWrapper_readable_impl(textio *self); |
1080 | | |
1081 | | static PyObject * |
1082 | | _io_TextIOWrapper_readable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1083 | 0 | { |
1084 | 0 | PyObject *return_value = NULL; |
1085 | |
|
1086 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1087 | 0 | return_value = _io_TextIOWrapper_readable_impl((textio *)self); |
1088 | 0 | Py_END_CRITICAL_SECTION(); |
1089 | |
|
1090 | 0 | return return_value; |
1091 | 0 | } |
1092 | | |
1093 | | PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__, |
1094 | | "writable($self, /)\n" |
1095 | | "--\n" |
1096 | | "\n"); |
1097 | | |
1098 | | #define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF \ |
1099 | | {"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__}, |
1100 | | |
1101 | | static PyObject * |
1102 | | _io_TextIOWrapper_writable_impl(textio *self); |
1103 | | |
1104 | | static PyObject * |
1105 | | _io_TextIOWrapper_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1106 | 0 | { |
1107 | 0 | PyObject *return_value = NULL; |
1108 | |
|
1109 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1110 | 0 | return_value = _io_TextIOWrapper_writable_impl((textio *)self); |
1111 | 0 | Py_END_CRITICAL_SECTION(); |
1112 | |
|
1113 | 0 | return return_value; |
1114 | 0 | } |
1115 | | |
1116 | | PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__, |
1117 | | "isatty($self, /)\n" |
1118 | | "--\n" |
1119 | | "\n"); |
1120 | | |
1121 | | #define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF \ |
1122 | | {"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__}, |
1123 | | |
1124 | | static PyObject * |
1125 | | _io_TextIOWrapper_isatty_impl(textio *self); |
1126 | | |
1127 | | static PyObject * |
1128 | | _io_TextIOWrapper_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1129 | 0 | { |
1130 | 0 | PyObject *return_value = NULL; |
1131 | |
|
1132 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1133 | 0 | return_value = _io_TextIOWrapper_isatty_impl((textio *)self); |
1134 | 0 | Py_END_CRITICAL_SECTION(); |
1135 | |
|
1136 | 0 | return return_value; |
1137 | 0 | } |
1138 | | |
1139 | | PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__, |
1140 | | "flush($self, /)\n" |
1141 | | "--\n" |
1142 | | "\n"); |
1143 | | |
1144 | | #define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF \ |
1145 | | {"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__}, |
1146 | | |
1147 | | static PyObject * |
1148 | | _io_TextIOWrapper_flush_impl(textio *self); |
1149 | | |
1150 | | static PyObject * |
1151 | | _io_TextIOWrapper_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1152 | 19 | { |
1153 | 19 | PyObject *return_value = NULL; |
1154 | | |
1155 | 19 | Py_BEGIN_CRITICAL_SECTION(self); |
1156 | 19 | return_value = _io_TextIOWrapper_flush_impl((textio *)self); |
1157 | 19 | Py_END_CRITICAL_SECTION(); |
1158 | | |
1159 | 19 | return return_value; |
1160 | 19 | } |
1161 | | |
1162 | | PyDoc_STRVAR(_io_TextIOWrapper_close__doc__, |
1163 | | "close($self, /)\n" |
1164 | | "--\n" |
1165 | | "\n"); |
1166 | | |
1167 | | #define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF \ |
1168 | | {"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__}, |
1169 | | |
1170 | | static PyObject * |
1171 | | _io_TextIOWrapper_close_impl(textio *self); |
1172 | | |
1173 | | static PyObject * |
1174 | | _io_TextIOWrapper_close(PyObject *self, PyObject *Py_UNUSED(ignored)) |
1175 | 19 | { |
1176 | 19 | PyObject *return_value = NULL; |
1177 | | |
1178 | 19 | Py_BEGIN_CRITICAL_SECTION(self); |
1179 | 19 | return_value = _io_TextIOWrapper_close_impl((textio *)self); |
1180 | 19 | Py_END_CRITICAL_SECTION(); |
1181 | | |
1182 | 19 | return return_value; |
1183 | 19 | } |
1184 | | |
1185 | | #if !defined(_io_TextIOWrapper_name_DOCSTR) |
1186 | | # define _io_TextIOWrapper_name_DOCSTR NULL |
1187 | | #endif |
1188 | | #if defined(_IO_TEXTIOWRAPPER_NAME_GETSETDEF) |
1189 | | # undef _IO_TEXTIOWRAPPER_NAME_GETSETDEF |
1190 | | # define _IO_TEXTIOWRAPPER_NAME_GETSETDEF {"name", (getter)_io_TextIOWrapper_name_get, (setter)_io_TextIOWrapper_name_set, _io_TextIOWrapper_name_DOCSTR}, |
1191 | | #else |
1192 | | # define _IO_TEXTIOWRAPPER_NAME_GETSETDEF {"name", (getter)_io_TextIOWrapper_name_get, NULL, _io_TextIOWrapper_name_DOCSTR}, |
1193 | | #endif |
1194 | | |
1195 | | static PyObject * |
1196 | | _io_TextIOWrapper_name_get_impl(textio *self); |
1197 | | |
1198 | | static PyObject * |
1199 | | _io_TextIOWrapper_name_get(PyObject *self, void *Py_UNUSED(context)) |
1200 | 0 | { |
1201 | 0 | PyObject *return_value = NULL; |
1202 | |
|
1203 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1204 | 0 | return_value = _io_TextIOWrapper_name_get_impl((textio *)self); |
1205 | 0 | Py_END_CRITICAL_SECTION(); |
1206 | |
|
1207 | 0 | return return_value; |
1208 | 0 | } |
1209 | | |
1210 | | #if !defined(_io_TextIOWrapper_closed_DOCSTR) |
1211 | | # define _io_TextIOWrapper_closed_DOCSTR NULL |
1212 | | #endif |
1213 | | #if defined(_IO_TEXTIOWRAPPER_CLOSED_GETSETDEF) |
1214 | | # undef _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF |
1215 | | # define _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF {"closed", (getter)_io_TextIOWrapper_closed_get, (setter)_io_TextIOWrapper_closed_set, _io_TextIOWrapper_closed_DOCSTR}, |
1216 | | #else |
1217 | | # define _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF {"closed", (getter)_io_TextIOWrapper_closed_get, NULL, _io_TextIOWrapper_closed_DOCSTR}, |
1218 | | #endif |
1219 | | |
1220 | | static PyObject * |
1221 | | _io_TextIOWrapper_closed_get_impl(textio *self); |
1222 | | |
1223 | | static PyObject * |
1224 | | _io_TextIOWrapper_closed_get(PyObject *self, void *Py_UNUSED(context)) |
1225 | 48 | { |
1226 | 48 | PyObject *return_value = NULL; |
1227 | | |
1228 | 48 | Py_BEGIN_CRITICAL_SECTION(self); |
1229 | 48 | return_value = _io_TextIOWrapper_closed_get_impl((textio *)self); |
1230 | 48 | Py_END_CRITICAL_SECTION(); |
1231 | | |
1232 | 48 | return return_value; |
1233 | 48 | } |
1234 | | |
1235 | | #if !defined(_io_TextIOWrapper_newlines_DOCSTR) |
1236 | | # define _io_TextIOWrapper_newlines_DOCSTR NULL |
1237 | | #endif |
1238 | | #if defined(_IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF) |
1239 | | # undef _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF |
1240 | | # define _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF {"newlines", (getter)_io_TextIOWrapper_newlines_get, (setter)_io_TextIOWrapper_newlines_set, _io_TextIOWrapper_newlines_DOCSTR}, |
1241 | | #else |
1242 | | # define _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF {"newlines", (getter)_io_TextIOWrapper_newlines_get, NULL, _io_TextIOWrapper_newlines_DOCSTR}, |
1243 | | #endif |
1244 | | |
1245 | | static PyObject * |
1246 | | _io_TextIOWrapper_newlines_get_impl(textio *self); |
1247 | | |
1248 | | static PyObject * |
1249 | | _io_TextIOWrapper_newlines_get(PyObject *self, void *Py_UNUSED(context)) |
1250 | 0 | { |
1251 | 0 | PyObject *return_value = NULL; |
1252 | |
|
1253 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1254 | 0 | return_value = _io_TextIOWrapper_newlines_get_impl((textio *)self); |
1255 | 0 | Py_END_CRITICAL_SECTION(); |
1256 | |
|
1257 | 0 | return return_value; |
1258 | 0 | } |
1259 | | |
1260 | | #if !defined(_io_TextIOWrapper_errors_DOCSTR) |
1261 | | # define _io_TextIOWrapper_errors_DOCSTR NULL |
1262 | | #endif |
1263 | | #if defined(_IO_TEXTIOWRAPPER_ERRORS_GETSETDEF) |
1264 | | # undef _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF |
1265 | | # define _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF {"errors", (getter)_io_TextIOWrapper_errors_get, (setter)_io_TextIOWrapper_errors_set, _io_TextIOWrapper_errors_DOCSTR}, |
1266 | | #else |
1267 | | # define _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF {"errors", (getter)_io_TextIOWrapper_errors_get, NULL, _io_TextIOWrapper_errors_DOCSTR}, |
1268 | | #endif |
1269 | | |
1270 | | static PyObject * |
1271 | | _io_TextIOWrapper_errors_get_impl(textio *self); |
1272 | | |
1273 | | static PyObject * |
1274 | | _io_TextIOWrapper_errors_get(PyObject *self, void *Py_UNUSED(context)) |
1275 | 0 | { |
1276 | 0 | PyObject *return_value = NULL; |
1277 | |
|
1278 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1279 | 0 | return_value = _io_TextIOWrapper_errors_get_impl((textio *)self); |
1280 | 0 | Py_END_CRITICAL_SECTION(); |
1281 | |
|
1282 | 0 | return return_value; |
1283 | 0 | } |
1284 | | |
1285 | | #if !defined(_io_TextIOWrapper__CHUNK_SIZE_DOCSTR) |
1286 | | # define _io_TextIOWrapper__CHUNK_SIZE_DOCSTR NULL |
1287 | | #endif |
1288 | | #if defined(_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF) |
1289 | | # undef _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF |
1290 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, |
1291 | | #else |
1292 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, NULL, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, |
1293 | | #endif |
1294 | | |
1295 | | static PyObject * |
1296 | | _io_TextIOWrapper__CHUNK_SIZE_get_impl(textio *self); |
1297 | | |
1298 | | static PyObject * |
1299 | | _io_TextIOWrapper__CHUNK_SIZE_get(PyObject *self, void *Py_UNUSED(context)) |
1300 | 0 | { |
1301 | 0 | PyObject *return_value = NULL; |
1302 | |
|
1303 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1304 | 0 | return_value = _io_TextIOWrapper__CHUNK_SIZE_get_impl((textio *)self); |
1305 | 0 | Py_END_CRITICAL_SECTION(); |
1306 | |
|
1307 | 0 | return return_value; |
1308 | 0 | } |
1309 | | |
1310 | | #if !defined(_io_TextIOWrapper__CHUNK_SIZE_DOCSTR) |
1311 | | # define _io_TextIOWrapper__CHUNK_SIZE_DOCSTR NULL |
1312 | | #endif |
1313 | | #if defined(_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF) |
1314 | | # undef _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF |
1315 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, |
1316 | | #else |
1317 | | # define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", NULL, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, NULL}, |
1318 | | #endif |
1319 | | |
1320 | | static int |
1321 | | _io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, PyObject *value); |
1322 | | |
1323 | | static int |
1324 | | _io_TextIOWrapper__CHUNK_SIZE_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) |
1325 | 0 | { |
1326 | 0 | int return_value; |
1327 | |
|
1328 | 0 | Py_BEGIN_CRITICAL_SECTION(self); |
1329 | 0 | return_value = _io_TextIOWrapper__CHUNK_SIZE_set_impl((textio *)self, value); |
1330 | 0 | Py_END_CRITICAL_SECTION(); |
1331 | |
|
1332 | 0 | return return_value; |
1333 | 0 | } |
1334 | | /*[clinic end generated code: output=8c571c9dba87d2b1 input=a9049054013a1b77]*/ |