Home | History | Annotate | Download | only in clinic
      1 /*[clinic input]
      2 preserve
      3 [clinic start generated code]*/
      4 
      5 PyDoc_STRVAR(_io_IncrementalNewlineDecoder___init____doc__,
      6 "IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n"
      7 "--\n"
      8 "\n"
      9 "Codec used when reading a file in universal newlines mode.\n"
     10 "\n"
     11 "It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n"
     12 "It also records the types of newlines encountered.  When used with\n"
     13 "translate=False, it ensures that the newline sequence is returned in\n"
     14 "one piece. When used with decoder=None, it expects unicode strings as\n"
     15 "decode input and translates newlines without first invoking an external\n"
     16 "decoder.");
     17 
     18 static int
     19 _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self,
     20                                             PyObject *decoder, int translate,
     21                                             PyObject *errors);
     22 
     23 static int
     24 _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
     25 {
     26     int return_value = -1;
     27     static const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
     28     static _PyArg_Parser _parser = {"Oi|O:IncrementalNewlineDecoder", _keywords, 0};
     29     PyObject *decoder;
     30     int translate;
     31     PyObject *errors = NULL;
     32 
     33     if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
     34         &decoder, &translate, &errors)) {
     35         goto exit;
     36     }
     37     return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
     38 
     39 exit:
     40     return return_value;
     41 }
     42 
     43 PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__,
     44 "decode($self, /, input, final=False)\n"
     45 "--\n"
     46 "\n");
     47 
     48 #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF    \
     49     {"decode", (PyCFunction)_io_IncrementalNewlineDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__},
     50 
     51 static PyObject *
     52 _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self,
     53                                           PyObject *input, int final);
     54 
     55 static PyObject *
     56 _io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     57 {
     58     PyObject *return_value = NULL;
     59     static const char * const _keywords[] = {"input", "final", NULL};
     60     static _PyArg_Parser _parser = {"O|i:decode", _keywords, 0};
     61     PyObject *input;
     62     int final = 0;
     63 
     64     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
     65         &input, &final)) {
     66         goto exit;
     67     }
     68     return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final);
     69 
     70 exit:
     71     return return_value;
     72 }
     73 
     74 PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__,
     75 "getstate($self, /)\n"
     76 "--\n"
     77 "\n");
     78 
     79 #define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF    \
     80     {"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__},
     81 
     82 static PyObject *
     83 _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self);
     84 
     85 static PyObject *
     86 _io_IncrementalNewlineDecoder_getstate(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
     87 {
     88     return _io_IncrementalNewlineDecoder_getstate_impl(self);
     89 }
     90 
     91 PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__,
     92 "setstate($self, state, /)\n"
     93 "--\n"
     94 "\n");
     95 
     96 #define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF    \
     97     {"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__},
     98 
     99 PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__,
    100 "reset($self, /)\n"
    101 "--\n"
    102 "\n");
    103 
    104 #define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF    \
    105     {"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__},
    106 
    107 static PyObject *
    108 _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self);
    109 
    110 static PyObject *
    111 _io_IncrementalNewlineDecoder_reset(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
    112 {
    113     return _io_IncrementalNewlineDecoder_reset_impl(self);
    114 }
    115 
    116 PyDoc_STRVAR(_io_TextIOWrapper___init____doc__,
    117 "TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n"
    118 "              line_buffering=False, write_through=False)\n"
    119 "--\n"
    120 "\n"
    121 "Character and line based layer over a BufferedIOBase object, buffer.\n"
    122 "\n"
    123 "encoding gives the name of the encoding that the stream will be\n"
    124 "decoded or encoded with. It defaults to locale.getpreferredencoding(False).\n"
    125 "\n"
    126 "errors determines the strictness of encoding and decoding (see\n"
    127 "help(codecs.Codec) or the documentation for codecs.register) and\n"
    128 "defaults to \"strict\".\n"
    129 "\n"
    130 "newline controls how line endings are handled. It can be None, \'\',\n"
    131 "\'\\n\', \'\\r\', and \'\\r\\n\'.  It works as follows:\n"
    132 "\n"
    133 "* On input, if newline is None, universal newlines mode is\n"
    134 "  enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n"
    135 "  these are translated into \'\\n\' before being returned to the\n"
    136 "  caller. If it is \'\', universal newline mode is enabled, but line\n"
    137 "  endings are returned to the caller untranslated. If it has any of\n"
    138 "  the other legal values, input lines are only terminated by the given\n"
    139 "  string, and the line ending is returned to the caller untranslated.\n"
    140 "\n"
    141 "* On output, if newline is None, any \'\\n\' characters written are\n"
    142 "  translated to the system default line separator, os.linesep. If\n"
    143 "  newline is \'\' or \'\\n\', no translation takes place. If newline is any\n"
    144 "  of the other legal values, any \'\\n\' characters written are translated\n"
    145 "  to the given string.\n"
    146 "\n"
    147 "If line_buffering is True, a call to flush is implied when a call to\n"
    148 "write contains a newline character.");
    149 
    150 static int
    151 _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
    152                                 const char *encoding, PyObject *errors,
    153                                 const char *newline, int line_buffering,
    154                                 int write_through);
    155 
    156 static int
    157 _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
    158 {
    159     int return_value = -1;
    160     static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
    161     static _PyArg_Parser _parser = {"O|zOzii:TextIOWrapper", _keywords, 0};
    162     PyObject *buffer;
    163     const char *encoding = NULL;
    164     PyObject *errors = Py_None;
    165     const char *newline = NULL;
    166     int line_buffering = 0;
    167     int write_through = 0;
    168 
    169     if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
    170         &buffer, &encoding, &errors, &newline, &line_buffering, &write_through)) {
    171         goto exit;
    172     }
    173     return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
    174 
    175 exit:
    176     return return_value;
    177 }
    178 
    179 PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__,
    180 "reconfigure($self, /, *, encoding=None, errors=None, newline=None,\n"
    181 "            line_buffering=None, write_through=None)\n"
    182 "--\n"
    183 "\n"
    184 "Reconfigure the text stream with new parameters.\n"
    185 "\n"
    186 "This also does an implicit stream flush.");
    187 
    188 #define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF    \
    189     {"reconfigure", (PyCFunction)_io_TextIOWrapper_reconfigure, METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__},
    190 
    191 static PyObject *
    192 _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding,
    193                                    PyObject *errors, PyObject *newline_obj,
    194                                    PyObject *line_buffering_obj,
    195                                    PyObject *write_through_obj);
    196 
    197 static PyObject *
    198 _io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    199 {
    200     PyObject *return_value = NULL;
    201     static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL};
    202     static _PyArg_Parser _parser = {"|$OOOOO:reconfigure", _keywords, 0};
    203     PyObject *encoding = Py_None;
    204     PyObject *errors = Py_None;
    205     PyObject *newline_obj = NULL;
    206     PyObject *line_buffering_obj = Py_None;
    207     PyObject *write_through_obj = Py_None;
    208 
    209     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
    210         &encoding, &errors, &newline_obj, &line_buffering_obj, &write_through_obj)) {
    211         goto exit;
    212     }
    213     return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj);
    214 
    215 exit:
    216     return return_value;
    217 }
    218 
    219 PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__,
    220 "detach($self, /)\n"
    221 "--\n"
    222 "\n");
    223 
    224 #define _IO_TEXTIOWRAPPER_DETACH_METHODDEF    \
    225     {"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__},
    226 
    227 static PyObject *
    228 _io_TextIOWrapper_detach_impl(textio *self);
    229 
    230 static PyObject *
    231 _io_TextIOWrapper_detach(textio *self, PyObject *Py_UNUSED(ignored))
    232 {
    233     return _io_TextIOWrapper_detach_impl(self);
    234 }
    235 
    236 PyDoc_STRVAR(_io_TextIOWrapper_write__doc__,
    237 "write($self, text, /)\n"
    238 "--\n"
    239 "\n");
    240 
    241 #define _IO_TEXTIOWRAPPER_WRITE_METHODDEF    \
    242     {"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__},
    243 
    244 static PyObject *
    245 _io_TextIOWrapper_write_impl(textio *self, PyObject *text);
    246 
    247 static PyObject *
    248 _io_TextIOWrapper_write(textio *self, PyObject *arg)
    249 {
    250     PyObject *return_value = NULL;
    251     PyObject *text;
    252 
    253     if (!PyArg_Parse(arg, "U:write", &text)) {
    254         goto exit;
    255     }
    256     return_value = _io_TextIOWrapper_write_impl(self, text);
    257 
    258 exit:
    259     return return_value;
    260 }
    261 
    262 PyDoc_STRVAR(_io_TextIOWrapper_read__doc__,
    263 "read($self, size=-1, /)\n"
    264 "--\n"
    265 "\n");
    266 
    267 #define _IO_TEXTIOWRAPPER_READ_METHODDEF    \
    268     {"read", (PyCFunction)_io_TextIOWrapper_read, METH_FASTCALL, _io_TextIOWrapper_read__doc__},
    269 
    270 static PyObject *
    271 _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n);
    272 
    273 static PyObject *
    274 _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs)
    275 {
    276     PyObject *return_value = NULL;
    277     Py_ssize_t n = -1;
    278 
    279     if (!_PyArg_ParseStack(args, nargs, "|O&:read",
    280         _Py_convert_optional_to_ssize_t, &n)) {
    281         goto exit;
    282     }
    283     return_value = _io_TextIOWrapper_read_impl(self, n);
    284 
    285 exit:
    286     return return_value;
    287 }
    288 
    289 PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__,
    290 "readline($self, size=-1, /)\n"
    291 "--\n"
    292 "\n");
    293 
    294 #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF    \
    295     {"readline", (PyCFunction)_io_TextIOWrapper_readline, METH_FASTCALL, _io_TextIOWrapper_readline__doc__},
    296 
    297 static PyObject *
    298 _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size);
    299 
    300 static PyObject *
    301 _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs)
    302 {
    303     PyObject *return_value = NULL;
    304     Py_ssize_t size = -1;
    305 
    306     if (!_PyArg_ParseStack(args, nargs, "|n:readline",
    307         &size)) {
    308         goto exit;
    309     }
    310     return_value = _io_TextIOWrapper_readline_impl(self, size);
    311 
    312 exit:
    313     return return_value;
    314 }
    315 
    316 PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__,
    317 "seek($self, cookie, whence=0, /)\n"
    318 "--\n"
    319 "\n");
    320 
    321 #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF    \
    322     {"seek", (PyCFunction)_io_TextIOWrapper_seek, METH_FASTCALL, _io_TextIOWrapper_seek__doc__},
    323 
    324 static PyObject *
    325 _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence);
    326 
    327 static PyObject *
    328 _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
    329 {
    330     PyObject *return_value = NULL;
    331     PyObject *cookieObj;
    332     int whence = 0;
    333 
    334     if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
    335         &cookieObj, &whence)) {
    336         goto exit;
    337     }
    338     return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
    339 
    340 exit:
    341     return return_value;
    342 }
    343 
    344 PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__,
    345 "tell($self, /)\n"
    346 "--\n"
    347 "\n");
    348 
    349 #define _IO_TEXTIOWRAPPER_TELL_METHODDEF    \
    350     {"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__},
    351 
    352 static PyObject *
    353 _io_TextIOWrapper_tell_impl(textio *self);
    354 
    355 static PyObject *
    356 _io_TextIOWrapper_tell(textio *self, PyObject *Py_UNUSED(ignored))
    357 {
    358     return _io_TextIOWrapper_tell_impl(self);
    359 }
    360 
    361 PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__,
    362 "truncate($self, pos=None, /)\n"
    363 "--\n"
    364 "\n");
    365 
    366 #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF    \
    367     {"truncate", (PyCFunction)_io_TextIOWrapper_truncate, METH_FASTCALL, _io_TextIOWrapper_truncate__doc__},
    368 
    369 static PyObject *
    370 _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos);
    371 
    372 static PyObject *
    373 _io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs)
    374 {
    375     PyObject *return_value = NULL;
    376     PyObject *pos = Py_None;
    377 
    378     if (!_PyArg_UnpackStack(args, nargs, "truncate",
    379         0, 1,
    380         &pos)) {
    381         goto exit;
    382     }
    383     return_value = _io_TextIOWrapper_truncate_impl(self, pos);
    384 
    385 exit:
    386     return return_value;
    387 }
    388 
    389 PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__,
    390 "fileno($self, /)\n"
    391 "--\n"
    392 "\n");
    393 
    394 #define _IO_TEXTIOWRAPPER_FILENO_METHODDEF    \
    395     {"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__},
    396 
    397 static PyObject *
    398 _io_TextIOWrapper_fileno_impl(textio *self);
    399 
    400 static PyObject *
    401 _io_TextIOWrapper_fileno(textio *self, PyObject *Py_UNUSED(ignored))
    402 {
    403     return _io_TextIOWrapper_fileno_impl(self);
    404 }
    405 
    406 PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__,
    407 "seekable($self, /)\n"
    408 "--\n"
    409 "\n");
    410 
    411 #define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF    \
    412     {"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__},
    413 
    414 static PyObject *
    415 _io_TextIOWrapper_seekable_impl(textio *self);
    416 
    417 static PyObject *
    418 _io_TextIOWrapper_seekable(textio *self, PyObject *Py_UNUSED(ignored))
    419 {
    420     return _io_TextIOWrapper_seekable_impl(self);
    421 }
    422 
    423 PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__,
    424 "readable($self, /)\n"
    425 "--\n"
    426 "\n");
    427 
    428 #define _IO_TEXTIOWRAPPER_READABLE_METHODDEF    \
    429     {"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__},
    430 
    431 static PyObject *
    432 _io_TextIOWrapper_readable_impl(textio *self);
    433 
    434 static PyObject *
    435 _io_TextIOWrapper_readable(textio *self, PyObject *Py_UNUSED(ignored))
    436 {
    437     return _io_TextIOWrapper_readable_impl(self);
    438 }
    439 
    440 PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__,
    441 "writable($self, /)\n"
    442 "--\n"
    443 "\n");
    444 
    445 #define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF    \
    446     {"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__},
    447 
    448 static PyObject *
    449 _io_TextIOWrapper_writable_impl(textio *self);
    450 
    451 static PyObject *
    452 _io_TextIOWrapper_writable(textio *self, PyObject *Py_UNUSED(ignored))
    453 {
    454     return _io_TextIOWrapper_writable_impl(self);
    455 }
    456 
    457 PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__,
    458 "isatty($self, /)\n"
    459 "--\n"
    460 "\n");
    461 
    462 #define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF    \
    463     {"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__},
    464 
    465 static PyObject *
    466 _io_TextIOWrapper_isatty_impl(textio *self);
    467 
    468 static PyObject *
    469 _io_TextIOWrapper_isatty(textio *self, PyObject *Py_UNUSED(ignored))
    470 {
    471     return _io_TextIOWrapper_isatty_impl(self);
    472 }
    473 
    474 PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__,
    475 "flush($self, /)\n"
    476 "--\n"
    477 "\n");
    478 
    479 #define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF    \
    480     {"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__},
    481 
    482 static PyObject *
    483 _io_TextIOWrapper_flush_impl(textio *self);
    484 
    485 static PyObject *
    486 _io_TextIOWrapper_flush(textio *self, PyObject *Py_UNUSED(ignored))
    487 {
    488     return _io_TextIOWrapper_flush_impl(self);
    489 }
    490 
    491 PyDoc_STRVAR(_io_TextIOWrapper_close__doc__,
    492 "close($self, /)\n"
    493 "--\n"
    494 "\n");
    495 
    496 #define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF    \
    497     {"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__},
    498 
    499 static PyObject *
    500 _io_TextIOWrapper_close_impl(textio *self);
    501 
    502 static PyObject *
    503 _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
    504 {
    505     return _io_TextIOWrapper_close_impl(self);
    506 }
    507 /*[clinic end generated code: output=b5be870b0039d577 input=a9049054013a1b77]*/
    508