LCOV - code coverage report
Current view: top level - Modules/_io/clinic - textio.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 108 222 48.6 %
Date: 2023-03-20 08:15:36 Functions: 10 20 50.0 %
Branches: 56 160 35.0 %

           Branch data     Line data    Source code
       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_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(_io_IncrementalNewlineDecoder___init____doc__,
      12                 :            : "IncrementalNewlineDecoder(decoder, translate, errors=\'strict\')\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Codec used when reading a file in universal newlines mode.\n"
      16                 :            : "\n"
      17                 :            : "It wraps another incremental decoder, translating \\r\\n and \\r into \\n.\n"
      18                 :            : "It also records the types of newlines encountered.  When used with\n"
      19                 :            : "translate=False, it ensures that the newline sequence is returned in\n"
      20                 :            : "one piece. When used with decoder=None, it expects unicode strings as\n"
      21                 :            : "decode input and translates newlines without first invoking an external\n"
      22                 :            : "decoder.");
      23                 :            : 
      24                 :            : static int
      25                 :            : _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self,
      26                 :            :                                             PyObject *decoder, int translate,
      27                 :            :                                             PyObject *errors);
      28                 :            : 
      29                 :            : static int
      30                 :        655 : _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
      31                 :            : {
      32                 :        655 :     int return_value = -1;
      33                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      34                 :            : 
      35                 :            :     #define NUM_KEYWORDS 3
      36                 :            :     static struct {
      37                 :            :         PyGC_Head _this_is_not_used;
      38                 :            :         PyObject_VAR_HEAD
      39                 :            :         PyObject *ob_item[NUM_KEYWORDS];
      40                 :            :     } _kwtuple = {
      41                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      42                 :            :         .ob_item = { &_Py_ID(decoder), &_Py_ID(translate), &_Py_ID(errors), },
      43                 :            :     };
      44                 :            :     #undef NUM_KEYWORDS
      45                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      46                 :            : 
      47                 :            :     #else  // !Py_BUILD_CORE
      48                 :            :     #  define KWTUPLE NULL
      49                 :            :     #endif  // !Py_BUILD_CORE
      50                 :            : 
      51                 :            :     static const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
      52                 :            :     static _PyArg_Parser _parser = {
      53                 :            :         .keywords = _keywords,
      54                 :            :         .fname = "IncrementalNewlineDecoder",
      55                 :            :         .kwtuple = KWTUPLE,
      56                 :            :     };
      57                 :            :     #undef KWTUPLE
      58                 :            :     PyObject *argsbuf[3];
      59                 :            :     PyObject * const *fastargs;
      60                 :        655 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
      61         [ -  + ]:        655 :     Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2;
      62                 :            :     PyObject *decoder;
      63                 :            :     int translate;
      64                 :        655 :     PyObject *errors = NULL;
      65                 :            : 
      66   [ +  -  +  -  :        655 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 3, 0, argsbuf);
             +  -  +  - ]
      67         [ -  + ]:        655 :     if (!fastargs) {
      68                 :          0 :         goto exit;
      69                 :            :     }
      70                 :        655 :     decoder = fastargs[0];
      71                 :        655 :     translate = PyObject_IsTrue(fastargs[1]);
      72         [ -  + ]:        655 :     if (translate < 0) {
      73                 :          0 :         goto exit;
      74                 :            :     }
      75         [ +  - ]:        655 :     if (!noptargs) {
      76                 :        655 :         goto skip_optional_pos;
      77                 :            :     }
      78                 :          0 :     errors = fastargs[2];
      79                 :        655 : skip_optional_pos:
      80                 :        655 :     return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
      81                 :            : 
      82                 :        655 : exit:
      83                 :        655 :     return return_value;
      84                 :            : }
      85                 :            : 
      86                 :            : PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__,
      87                 :            : "decode($self, /, input, final=False)\n"
      88                 :            : "--\n"
      89                 :            : "\n");
      90                 :            : 
      91                 :            : #define _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF    \
      92                 :            :     {"decode", _PyCFunction_CAST(_io_IncrementalNewlineDecoder_decode), METH_FASTCALL|METH_KEYWORDS, _io_IncrementalNewlineDecoder_decode__doc__},
      93                 :            : 
      94                 :            : static PyObject *
      95                 :            : _io_IncrementalNewlineDecoder_decode_impl(nldecoder_object *self,
      96                 :            :                                           PyObject *input, int final);
      97                 :            : 
      98                 :            : static PyObject *
      99                 :          1 : _io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     100                 :            : {
     101                 :          1 :     PyObject *return_value = NULL;
     102                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     103                 :            : 
     104                 :            :     #define NUM_KEYWORDS 2
     105                 :            :     static struct {
     106                 :            :         PyGC_Head _this_is_not_used;
     107                 :            :         PyObject_VAR_HEAD
     108                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     109                 :            :     } _kwtuple = {
     110                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     111                 :            :         .ob_item = { &_Py_ID(input), &_Py_ID(final), },
     112                 :            :     };
     113                 :            :     #undef NUM_KEYWORDS
     114                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     115                 :            : 
     116                 :            :     #else  // !Py_BUILD_CORE
     117                 :            :     #  define KWTUPLE NULL
     118                 :            :     #endif  // !Py_BUILD_CORE
     119                 :            : 
     120                 :            :     static const char * const _keywords[] = {"input", "final", NULL};
     121                 :            :     static _PyArg_Parser _parser = {
     122                 :            :         .keywords = _keywords,
     123                 :            :         .fname = "decode",
     124                 :            :         .kwtuple = KWTUPLE,
     125                 :            :     };
     126                 :            :     #undef KWTUPLE
     127                 :            :     PyObject *argsbuf[2];
     128         [ -  + ]:          1 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     129                 :            :     PyObject *input;
     130                 :          1 :     int final = 0;
     131                 :            : 
     132   [ +  -  +  -  :          1 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
             +  -  -  + ]
     133         [ -  + ]:          1 :     if (!args) {
     134                 :          0 :         goto exit;
     135                 :            :     }
     136                 :          1 :     input = args[0];
     137         [ -  + ]:          1 :     if (!noptargs) {
     138                 :          0 :         goto skip_optional_pos;
     139                 :            :     }
     140                 :          1 :     final = PyObject_IsTrue(args[1]);
     141         [ -  + ]:          1 :     if (final < 0) {
     142                 :          0 :         goto exit;
     143                 :            :     }
     144                 :          1 : skip_optional_pos:
     145                 :          1 :     return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final);
     146                 :            : 
     147                 :          1 : exit:
     148                 :          1 :     return return_value;
     149                 :            : }
     150                 :            : 
     151                 :            : PyDoc_STRVAR(_io_IncrementalNewlineDecoder_getstate__doc__,
     152                 :            : "getstate($self, /)\n"
     153                 :            : "--\n"
     154                 :            : "\n");
     155                 :            : 
     156                 :            : #define _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF    \
     157                 :            :     {"getstate", (PyCFunction)_io_IncrementalNewlineDecoder_getstate, METH_NOARGS, _io_IncrementalNewlineDecoder_getstate__doc__},
     158                 :            : 
     159                 :            : static PyObject *
     160                 :            : _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self);
     161                 :            : 
     162                 :            : static PyObject *
     163                 :          8 : _io_IncrementalNewlineDecoder_getstate(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
     164                 :            : {
     165                 :          8 :     return _io_IncrementalNewlineDecoder_getstate_impl(self);
     166                 :            : }
     167                 :            : 
     168                 :            : PyDoc_STRVAR(_io_IncrementalNewlineDecoder_setstate__doc__,
     169                 :            : "setstate($self, state, /)\n"
     170                 :            : "--\n"
     171                 :            : "\n");
     172                 :            : 
     173                 :            : #define _IO_INCREMENTALNEWLINEDECODER_SETSTATE_METHODDEF    \
     174                 :            :     {"setstate", (PyCFunction)_io_IncrementalNewlineDecoder_setstate, METH_O, _io_IncrementalNewlineDecoder_setstate__doc__},
     175                 :            : 
     176                 :            : PyDoc_STRVAR(_io_IncrementalNewlineDecoder_reset__doc__,
     177                 :            : "reset($self, /)\n"
     178                 :            : "--\n"
     179                 :            : "\n");
     180                 :            : 
     181                 :            : #define _IO_INCREMENTALNEWLINEDECODER_RESET_METHODDEF    \
     182                 :            :     {"reset", (PyCFunction)_io_IncrementalNewlineDecoder_reset, METH_NOARGS, _io_IncrementalNewlineDecoder_reset__doc__},
     183                 :            : 
     184                 :            : static PyObject *
     185                 :            : _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self);
     186                 :            : 
     187                 :            : static PyObject *
     188                 :          0 : _io_IncrementalNewlineDecoder_reset(nldecoder_object *self, PyObject *Py_UNUSED(ignored))
     189                 :            : {
     190                 :          0 :     return _io_IncrementalNewlineDecoder_reset_impl(self);
     191                 :            : }
     192                 :            : 
     193                 :            : PyDoc_STRVAR(_io_TextIOWrapper___init____doc__,
     194                 :            : "TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n"
     195                 :            : "              line_buffering=False, write_through=False)\n"
     196                 :            : "--\n"
     197                 :            : "\n"
     198                 :            : "Character and line based layer over a BufferedIOBase object, buffer.\n"
     199                 :            : "\n"
     200                 :            : "encoding gives the name of the encoding that the stream will be\n"
     201                 :            : "decoded or encoded with. It defaults to locale.getencoding().\n"
     202                 :            : "\n"
     203                 :            : "errors determines the strictness of encoding and decoding (see\n"
     204                 :            : "help(codecs.Codec) or the documentation for codecs.register) and\n"
     205                 :            : "defaults to \"strict\".\n"
     206                 :            : "\n"
     207                 :            : "newline controls how line endings are handled. It can be None, \'\',\n"
     208                 :            : "\'\\n\', \'\\r\', and \'\\r\\n\'.  It works as follows:\n"
     209                 :            : "\n"
     210                 :            : "* On input, if newline is None, universal newlines mode is\n"
     211                 :            : "  enabled. Lines in the input can end in \'\\n\', \'\\r\', or \'\\r\\n\', and\n"
     212                 :            : "  these are translated into \'\\n\' before being returned to the\n"
     213                 :            : "  caller. If it is \'\', universal newline mode is enabled, but line\n"
     214                 :            : "  endings are returned to the caller untranslated. If it has any of\n"
     215                 :            : "  the other legal values, input lines are only terminated by the given\n"
     216                 :            : "  string, and the line ending is returned to the caller untranslated.\n"
     217                 :            : "\n"
     218                 :            : "* On output, if newline is None, any \'\\n\' characters written are\n"
     219                 :            : "  translated to the system default line separator, os.linesep. If\n"
     220                 :            : "  newline is \'\' or \'\\n\', no translation takes place. If newline is any\n"
     221                 :            : "  of the other legal values, any \'\\n\' characters written are translated\n"
     222                 :            : "  to the given string.\n"
     223                 :            : "\n"
     224                 :            : "If line_buffering is True, a call to flush is implied when a call to\n"
     225                 :            : "write contains a newline character.");
     226                 :            : 
     227                 :            : static int
     228                 :            : _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
     229                 :            :                                 const char *encoding, PyObject *errors,
     230                 :            :                                 const char *newline, int line_buffering,
     231                 :            :                                 int write_through);
     232                 :            : 
     233                 :            : static int
     234                 :        753 : _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
     235                 :            : {
     236                 :        753 :     int return_value = -1;
     237                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     238                 :            : 
     239                 :            :     #define NUM_KEYWORDS 6
     240                 :            :     static struct {
     241                 :            :         PyGC_Head _this_is_not_used;
     242                 :            :         PyObject_VAR_HEAD
     243                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     244                 :            :     } _kwtuple = {
     245                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     246                 :            :         .ob_item = { &_Py_ID(buffer), &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), },
     247                 :            :     };
     248                 :            :     #undef NUM_KEYWORDS
     249                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     250                 :            : 
     251                 :            :     #else  // !Py_BUILD_CORE
     252                 :            :     #  define KWTUPLE NULL
     253                 :            :     #endif  // !Py_BUILD_CORE
     254                 :            : 
     255                 :            :     static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
     256                 :            :     static _PyArg_Parser _parser = {
     257                 :            :         .keywords = _keywords,
     258                 :            :         .fname = "TextIOWrapper",
     259                 :            :         .kwtuple = KWTUPLE,
     260                 :            :     };
     261                 :            :     #undef KWTUPLE
     262                 :            :     PyObject *argsbuf[6];
     263                 :            :     PyObject * const *fastargs;
     264                 :        753 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
     265         [ +  + ]:        753 :     Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
     266                 :            :     PyObject *buffer;
     267                 :        753 :     const char *encoding = NULL;
     268                 :        753 :     PyObject *errors = Py_None;
     269                 :        753 :     const char *newline = NULL;
     270                 :        753 :     int line_buffering = 0;
     271                 :        753 :     int write_through = 0;
     272                 :            : 
     273   [ +  +  +  -  :        753 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 6, 0, argsbuf);
             +  -  +  - ]
     274         [ -  + ]:        753 :     if (!fastargs) {
     275                 :          0 :         goto exit;
     276                 :            :     }
     277                 :        753 :     buffer = fastargs[0];
     278         [ -  + ]:        753 :     if (!noptargs) {
     279                 :          0 :         goto skip_optional_pos;
     280                 :            :     }
     281         [ +  - ]:        753 :     if (fastargs[1]) {
     282         [ +  + ]:        753 :         if (fastargs[1] == Py_None) {
     283                 :         20 :             encoding = NULL;
     284                 :            :         }
     285         [ +  - ]:        733 :         else if (PyUnicode_Check(fastargs[1])) {
     286                 :            :             Py_ssize_t encoding_length;
     287                 :        733 :             encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length);
     288         [ -  + ]:        733 :             if (encoding == NULL) {
     289                 :          0 :                 goto exit;
     290                 :            :             }
     291         [ -  + ]:        733 :             if (strlen(encoding) != (size_t)encoding_length) {
     292                 :          0 :                 PyErr_SetString(PyExc_ValueError, "embedded null character");
     293                 :          0 :                 goto exit;
     294                 :            :             }
     295                 :            :         }
     296                 :            :         else {
     297                 :          0 :             _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]);
     298                 :          0 :             goto exit;
     299                 :            :         }
     300         [ -  + ]:        753 :         if (!--noptargs) {
     301                 :          0 :             goto skip_optional_pos;
     302                 :            :         }
     303                 :            :     }
     304         [ +  + ]:        753 :     if (fastargs[2]) {
     305                 :        752 :         errors = fastargs[2];
     306         [ -  + ]:        752 :         if (!--noptargs) {
     307                 :          0 :             goto skip_optional_pos;
     308                 :            :         }
     309                 :            :     }
     310         [ +  + ]:        753 :     if (fastargs[3]) {
     311         [ +  + ]:        752 :         if (fastargs[3] == Py_None) {
     312                 :        676 :             newline = NULL;
     313                 :            :         }
     314         [ +  - ]:         76 :         else if (PyUnicode_Check(fastargs[3])) {
     315                 :            :             Py_ssize_t newline_length;
     316                 :         76 :             newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length);
     317         [ -  + ]:         76 :             if (newline == NULL) {
     318                 :          0 :                 goto exit;
     319                 :            :             }
     320         [ -  + ]:         76 :             if (strlen(newline) != (size_t)newline_length) {
     321                 :          0 :                 PyErr_SetString(PyExc_ValueError, "embedded null character");
     322                 :          0 :                 goto exit;
     323                 :            :             }
     324                 :            :         }
     325                 :            :         else {
     326                 :          0 :             _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]);
     327                 :          0 :             goto exit;
     328                 :            :         }
     329         [ -  + ]:        752 :         if (!--noptargs) {
     330                 :          0 :             goto skip_optional_pos;
     331                 :            :         }
     332                 :            :     }
     333         [ +  - ]:        753 :     if (fastargs[4]) {
     334                 :        753 :         line_buffering = PyObject_IsTrue(fastargs[4]);
     335         [ -  + ]:        753 :         if (line_buffering < 0) {
     336                 :          0 :             goto exit;
     337                 :            :         }
     338         [ +  + ]:        753 :         if (!--noptargs) {
     339                 :        678 :             goto skip_optional_pos;
     340                 :            :         }
     341                 :            :     }
     342                 :         75 :     write_through = PyObject_IsTrue(fastargs[5]);
     343         [ -  + ]:         75 :     if (write_through < 0) {
     344                 :          0 :         goto exit;
     345                 :            :     }
     346                 :         75 : skip_optional_pos:
     347                 :        753 :     return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
     348                 :            : 
     349                 :        753 : exit:
     350                 :        753 :     return return_value;
     351                 :            : }
     352                 :            : 
     353                 :            : PyDoc_STRVAR(_io_TextIOWrapper_reconfigure__doc__,
     354                 :            : "reconfigure($self, /, *, encoding=None, errors=None, newline=None,\n"
     355                 :            : "            line_buffering=None, write_through=None)\n"
     356                 :            : "--\n"
     357                 :            : "\n"
     358                 :            : "Reconfigure the text stream with new parameters.\n"
     359                 :            : "\n"
     360                 :            : "This also does an implicit stream flush.");
     361                 :            : 
     362                 :            : #define _IO_TEXTIOWRAPPER_RECONFIGURE_METHODDEF    \
     363                 :            :     {"reconfigure", _PyCFunction_CAST(_io_TextIOWrapper_reconfigure), METH_FASTCALL|METH_KEYWORDS, _io_TextIOWrapper_reconfigure__doc__},
     364                 :            : 
     365                 :            : static PyObject *
     366                 :            : _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding,
     367                 :            :                                    PyObject *errors, PyObject *newline_obj,
     368                 :            :                                    PyObject *line_buffering_obj,
     369                 :            :                                    PyObject *write_through_obj);
     370                 :            : 
     371                 :            : static PyObject *
     372                 :          0 : _io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     373                 :            : {
     374                 :          0 :     PyObject *return_value = NULL;
     375                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     376                 :            : 
     377                 :            :     #define NUM_KEYWORDS 5
     378                 :            :     static struct {
     379                 :            :         PyGC_Head _this_is_not_used;
     380                 :            :         PyObject_VAR_HEAD
     381                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     382                 :            :     } _kwtuple = {
     383                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     384                 :            :         .ob_item = { &_Py_ID(encoding), &_Py_ID(errors), &_Py_ID(newline), &_Py_ID(line_buffering), &_Py_ID(write_through), },
     385                 :            :     };
     386                 :            :     #undef NUM_KEYWORDS
     387                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     388                 :            : 
     389                 :            :     #else  // !Py_BUILD_CORE
     390                 :            :     #  define KWTUPLE NULL
     391                 :            :     #endif  // !Py_BUILD_CORE
     392                 :            : 
     393                 :            :     static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL};
     394                 :            :     static _PyArg_Parser _parser = {
     395                 :            :         .keywords = _keywords,
     396                 :            :         .fname = "reconfigure",
     397                 :            :         .kwtuple = KWTUPLE,
     398                 :            :     };
     399                 :            :     #undef KWTUPLE
     400                 :            :     PyObject *argsbuf[5];
     401         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     402                 :          0 :     PyObject *encoding = Py_None;
     403                 :          0 :     PyObject *errors = Py_None;
     404                 :          0 :     PyObject *newline_obj = NULL;
     405                 :          0 :     PyObject *line_buffering_obj = Py_None;
     406                 :          0 :     PyObject *write_through_obj = Py_None;
     407                 :            : 
     408   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
             #  #  #  # ]
     409         [ #  # ]:          0 :     if (!args) {
     410                 :          0 :         goto exit;
     411                 :            :     }
     412         [ #  # ]:          0 :     if (!noptargs) {
     413                 :          0 :         goto skip_optional_kwonly;
     414                 :            :     }
     415         [ #  # ]:          0 :     if (args[0]) {
     416                 :          0 :         encoding = args[0];
     417         [ #  # ]:          0 :         if (!--noptargs) {
     418                 :          0 :             goto skip_optional_kwonly;
     419                 :            :         }
     420                 :            :     }
     421         [ #  # ]:          0 :     if (args[1]) {
     422                 :          0 :         errors = args[1];
     423         [ #  # ]:          0 :         if (!--noptargs) {
     424                 :          0 :             goto skip_optional_kwonly;
     425                 :            :         }
     426                 :            :     }
     427         [ #  # ]:          0 :     if (args[2]) {
     428                 :          0 :         newline_obj = args[2];
     429         [ #  # ]:          0 :         if (!--noptargs) {
     430                 :          0 :             goto skip_optional_kwonly;
     431                 :            :         }
     432                 :            :     }
     433         [ #  # ]:          0 :     if (args[3]) {
     434                 :          0 :         line_buffering_obj = args[3];
     435         [ #  # ]:          0 :         if (!--noptargs) {
     436                 :          0 :             goto skip_optional_kwonly;
     437                 :            :         }
     438                 :            :     }
     439                 :          0 :     write_through_obj = args[4];
     440                 :          0 : skip_optional_kwonly:
     441                 :          0 :     return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj);
     442                 :            : 
     443                 :          0 : exit:
     444                 :          0 :     return return_value;
     445                 :            : }
     446                 :            : 
     447                 :            : PyDoc_STRVAR(_io_TextIOWrapper_detach__doc__,
     448                 :            : "detach($self, /)\n"
     449                 :            : "--\n"
     450                 :            : "\n");
     451                 :            : 
     452                 :            : #define _IO_TEXTIOWRAPPER_DETACH_METHODDEF    \
     453                 :            :     {"detach", (PyCFunction)_io_TextIOWrapper_detach, METH_NOARGS, _io_TextIOWrapper_detach__doc__},
     454                 :            : 
     455                 :            : static PyObject *
     456                 :            : _io_TextIOWrapper_detach_impl(textio *self);
     457                 :            : 
     458                 :            : static PyObject *
     459                 :          0 : _io_TextIOWrapper_detach(textio *self, PyObject *Py_UNUSED(ignored))
     460                 :            : {
     461                 :          0 :     return _io_TextIOWrapper_detach_impl(self);
     462                 :            : }
     463                 :            : 
     464                 :            : PyDoc_STRVAR(_io_TextIOWrapper_write__doc__,
     465                 :            : "write($self, text, /)\n"
     466                 :            : "--\n"
     467                 :            : "\n");
     468                 :            : 
     469                 :            : #define _IO_TEXTIOWRAPPER_WRITE_METHODDEF    \
     470                 :            :     {"write", (PyCFunction)_io_TextIOWrapper_write, METH_O, _io_TextIOWrapper_write__doc__},
     471                 :            : 
     472                 :            : static PyObject *
     473                 :            : _io_TextIOWrapper_write_impl(textio *self, PyObject *text);
     474                 :            : 
     475                 :            : static PyObject *
     476                 :     492806 : _io_TextIOWrapper_write(textio *self, PyObject *arg)
     477                 :            : {
     478                 :     492806 :     PyObject *return_value = NULL;
     479                 :            :     PyObject *text;
     480                 :            : 
     481         [ -  + ]:     492806 :     if (!PyUnicode_Check(arg)) {
     482                 :          0 :         _PyArg_BadArgument("write", "argument", "str", arg);
     483                 :          0 :         goto exit;
     484                 :            :     }
     485         [ -  + ]:     492806 :     if (PyUnicode_READY(arg) == -1) {
     486                 :          0 :         goto exit;
     487                 :            :     }
     488                 :     492806 :     text = arg;
     489                 :     492806 :     return_value = _io_TextIOWrapper_write_impl(self, text);
     490                 :            : 
     491                 :     492806 : exit:
     492                 :     492806 :     return return_value;
     493                 :            : }
     494                 :            : 
     495                 :            : PyDoc_STRVAR(_io_TextIOWrapper_read__doc__,
     496                 :            : "read($self, size=-1, /)\n"
     497                 :            : "--\n"
     498                 :            : "\n");
     499                 :            : 
     500                 :            : #define _IO_TEXTIOWRAPPER_READ_METHODDEF    \
     501                 :            :     {"read", _PyCFunction_CAST(_io_TextIOWrapper_read), METH_FASTCALL, _io_TextIOWrapper_read__doc__},
     502                 :            : 
     503                 :            : static PyObject *
     504                 :            : _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n);
     505                 :            : 
     506                 :            : static PyObject *
     507                 :         24 : _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs)
     508                 :            : {
     509                 :         24 :     PyObject *return_value = NULL;
     510                 :         24 :     Py_ssize_t n = -1;
     511                 :            : 
     512   [ +  -  -  +  :         24 :     if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
                   -  - ]
     513                 :          0 :         goto exit;
     514                 :            :     }
     515         [ +  - ]:         24 :     if (nargs < 1) {
     516                 :         24 :         goto skip_optional;
     517                 :            :     }
     518         [ #  # ]:          0 :     if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
     519                 :          0 :         goto exit;
     520                 :            :     }
     521                 :          0 : skip_optional:
     522                 :         24 :     return_value = _io_TextIOWrapper_read_impl(self, n);
     523                 :            : 
     524                 :         24 : exit:
     525                 :         24 :     return return_value;
     526                 :            : }
     527                 :            : 
     528                 :            : PyDoc_STRVAR(_io_TextIOWrapper_readline__doc__,
     529                 :            : "readline($self, size=-1, /)\n"
     530                 :            : "--\n"
     531                 :            : "\n");
     532                 :            : 
     533                 :            : #define _IO_TEXTIOWRAPPER_READLINE_METHODDEF    \
     534                 :            :     {"readline", _PyCFunction_CAST(_io_TextIOWrapper_readline), METH_FASTCALL, _io_TextIOWrapper_readline__doc__},
     535                 :            : 
     536                 :            : static PyObject *
     537                 :            : _io_TextIOWrapper_readline_impl(textio *self, Py_ssize_t size);
     538                 :            : 
     539                 :            : static PyObject *
     540                 :       1874 : _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs)
     541                 :            : {
     542                 :       1874 :     PyObject *return_value = NULL;
     543                 :       1874 :     Py_ssize_t size = -1;
     544                 :            : 
     545   [ +  -  -  +  :       1874 :     if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
                   -  - ]
     546                 :          0 :         goto exit;
     547                 :            :     }
     548         [ +  - ]:       1874 :     if (nargs < 1) {
     549                 :       1874 :         goto skip_optional;
     550                 :            :     }
     551                 :            :     {
     552                 :          0 :         Py_ssize_t ival = -1;
     553                 :          0 :         PyObject *iobj = _PyNumber_Index(args[0]);
     554         [ #  # ]:          0 :         if (iobj != NULL) {
     555                 :          0 :             ival = PyLong_AsSsize_t(iobj);
     556                 :          0 :             Py_DECREF(iobj);
     557                 :            :         }
     558   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
     559                 :          0 :             goto exit;
     560                 :            :         }
     561                 :          0 :         size = ival;
     562                 :            :     }
     563                 :       1874 : skip_optional:
     564                 :       1874 :     return_value = _io_TextIOWrapper_readline_impl(self, size);
     565                 :            : 
     566                 :       1874 : exit:
     567                 :       1874 :     return return_value;
     568                 :            : }
     569                 :            : 
     570                 :            : PyDoc_STRVAR(_io_TextIOWrapper_seek__doc__,
     571                 :            : "seek($self, cookie, whence=0, /)\n"
     572                 :            : "--\n"
     573                 :            : "\n");
     574                 :            : 
     575                 :            : #define _IO_TEXTIOWRAPPER_SEEK_METHODDEF    \
     576                 :            :     {"seek", _PyCFunction_CAST(_io_TextIOWrapper_seek), METH_FASTCALL, _io_TextIOWrapper_seek__doc__},
     577                 :            : 
     578                 :            : static PyObject *
     579                 :            : _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence);
     580                 :            : 
     581                 :            : static PyObject *
     582                 :          0 : _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
     583                 :            : {
     584                 :          0 :     PyObject *return_value = NULL;
     585                 :            :     PyObject *cookieObj;
     586                 :          0 :     int whence = 0;
     587                 :            : 
     588   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
                   #  # ]
     589                 :          0 :         goto exit;
     590                 :            :     }
     591                 :          0 :     cookieObj = args[0];
     592         [ #  # ]:          0 :     if (nargs < 2) {
     593                 :          0 :         goto skip_optional;
     594                 :            :     }
     595                 :          0 :     whence = _PyLong_AsInt(args[1]);
     596   [ #  #  #  # ]:          0 :     if (whence == -1 && PyErr_Occurred()) {
     597                 :          0 :         goto exit;
     598                 :            :     }
     599                 :          0 : skip_optional:
     600                 :          0 :     return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
     601                 :            : 
     602                 :          0 : exit:
     603                 :          0 :     return return_value;
     604                 :            : }
     605                 :            : 
     606                 :            : PyDoc_STRVAR(_io_TextIOWrapper_tell__doc__,
     607                 :            : "tell($self, /)\n"
     608                 :            : "--\n"
     609                 :            : "\n");
     610                 :            : 
     611                 :            : #define _IO_TEXTIOWRAPPER_TELL_METHODDEF    \
     612                 :            :     {"tell", (PyCFunction)_io_TextIOWrapper_tell, METH_NOARGS, _io_TextIOWrapper_tell__doc__},
     613                 :            : 
     614                 :            : static PyObject *
     615                 :            : _io_TextIOWrapper_tell_impl(textio *self);
     616                 :            : 
     617                 :            : static PyObject *
     618                 :          0 : _io_TextIOWrapper_tell(textio *self, PyObject *Py_UNUSED(ignored))
     619                 :            : {
     620                 :          0 :     return _io_TextIOWrapper_tell_impl(self);
     621                 :            : }
     622                 :            : 
     623                 :            : PyDoc_STRVAR(_io_TextIOWrapper_truncate__doc__,
     624                 :            : "truncate($self, pos=None, /)\n"
     625                 :            : "--\n"
     626                 :            : "\n");
     627                 :            : 
     628                 :            : #define _IO_TEXTIOWRAPPER_TRUNCATE_METHODDEF    \
     629                 :            :     {"truncate", _PyCFunction_CAST(_io_TextIOWrapper_truncate), METH_FASTCALL, _io_TextIOWrapper_truncate__doc__},
     630                 :            : 
     631                 :            : static PyObject *
     632                 :            : _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos);
     633                 :            : 
     634                 :            : static PyObject *
     635                 :          0 : _io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs)
     636                 :            : {
     637                 :          0 :     PyObject *return_value = NULL;
     638                 :          0 :     PyObject *pos = Py_None;
     639                 :            : 
     640   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
                   #  # ]
     641                 :          0 :         goto exit;
     642                 :            :     }
     643         [ #  # ]:          0 :     if (nargs < 1) {
     644                 :          0 :         goto skip_optional;
     645                 :            :     }
     646                 :          0 :     pos = args[0];
     647                 :          0 : skip_optional:
     648                 :          0 :     return_value = _io_TextIOWrapper_truncate_impl(self, pos);
     649                 :            : 
     650                 :          0 : exit:
     651                 :          0 :     return return_value;
     652                 :            : }
     653                 :            : 
     654                 :            : PyDoc_STRVAR(_io_TextIOWrapper_fileno__doc__,
     655                 :            : "fileno($self, /)\n"
     656                 :            : "--\n"
     657                 :            : "\n");
     658                 :            : 
     659                 :            : #define _IO_TEXTIOWRAPPER_FILENO_METHODDEF    \
     660                 :            :     {"fileno", (PyCFunction)_io_TextIOWrapper_fileno, METH_NOARGS, _io_TextIOWrapper_fileno__doc__},
     661                 :            : 
     662                 :            : static PyObject *
     663                 :            : _io_TextIOWrapper_fileno_impl(textio *self);
     664                 :            : 
     665                 :            : static PyObject *
     666                 :         13 : _io_TextIOWrapper_fileno(textio *self, PyObject *Py_UNUSED(ignored))
     667                 :            : {
     668                 :         13 :     return _io_TextIOWrapper_fileno_impl(self);
     669                 :            : }
     670                 :            : 
     671                 :            : PyDoc_STRVAR(_io_TextIOWrapper_seekable__doc__,
     672                 :            : "seekable($self, /)\n"
     673                 :            : "--\n"
     674                 :            : "\n");
     675                 :            : 
     676                 :            : #define _IO_TEXTIOWRAPPER_SEEKABLE_METHODDEF    \
     677                 :            :     {"seekable", (PyCFunction)_io_TextIOWrapper_seekable, METH_NOARGS, _io_TextIOWrapper_seekable__doc__},
     678                 :            : 
     679                 :            : static PyObject *
     680                 :            : _io_TextIOWrapper_seekable_impl(textio *self);
     681                 :            : 
     682                 :            : static PyObject *
     683                 :          0 : _io_TextIOWrapper_seekable(textio *self, PyObject *Py_UNUSED(ignored))
     684                 :            : {
     685                 :          0 :     return _io_TextIOWrapper_seekable_impl(self);
     686                 :            : }
     687                 :            : 
     688                 :            : PyDoc_STRVAR(_io_TextIOWrapper_readable__doc__,
     689                 :            : "readable($self, /)\n"
     690                 :            : "--\n"
     691                 :            : "\n");
     692                 :            : 
     693                 :            : #define _IO_TEXTIOWRAPPER_READABLE_METHODDEF    \
     694                 :            :     {"readable", (PyCFunction)_io_TextIOWrapper_readable, METH_NOARGS, _io_TextIOWrapper_readable__doc__},
     695                 :            : 
     696                 :            : static PyObject *
     697                 :            : _io_TextIOWrapper_readable_impl(textio *self);
     698                 :            : 
     699                 :            : static PyObject *
     700                 :          0 : _io_TextIOWrapper_readable(textio *self, PyObject *Py_UNUSED(ignored))
     701                 :            : {
     702                 :          0 :     return _io_TextIOWrapper_readable_impl(self);
     703                 :            : }
     704                 :            : 
     705                 :            : PyDoc_STRVAR(_io_TextIOWrapper_writable__doc__,
     706                 :            : "writable($self, /)\n"
     707                 :            : "--\n"
     708                 :            : "\n");
     709                 :            : 
     710                 :            : #define _IO_TEXTIOWRAPPER_WRITABLE_METHODDEF    \
     711                 :            :     {"writable", (PyCFunction)_io_TextIOWrapper_writable, METH_NOARGS, _io_TextIOWrapper_writable__doc__},
     712                 :            : 
     713                 :            : static PyObject *
     714                 :            : _io_TextIOWrapper_writable_impl(textio *self);
     715                 :            : 
     716                 :            : static PyObject *
     717                 :          0 : _io_TextIOWrapper_writable(textio *self, PyObject *Py_UNUSED(ignored))
     718                 :            : {
     719                 :          0 :     return _io_TextIOWrapper_writable_impl(self);
     720                 :            : }
     721                 :            : 
     722                 :            : PyDoc_STRVAR(_io_TextIOWrapper_isatty__doc__,
     723                 :            : "isatty($self, /)\n"
     724                 :            : "--\n"
     725                 :            : "\n");
     726                 :            : 
     727                 :            : #define _IO_TEXTIOWRAPPER_ISATTY_METHODDEF    \
     728                 :            :     {"isatty", (PyCFunction)_io_TextIOWrapper_isatty, METH_NOARGS, _io_TextIOWrapper_isatty__doc__},
     729                 :            : 
     730                 :            : static PyObject *
     731                 :            : _io_TextIOWrapper_isatty_impl(textio *self);
     732                 :            : 
     733                 :            : static PyObject *
     734                 :          0 : _io_TextIOWrapper_isatty(textio *self, PyObject *Py_UNUSED(ignored))
     735                 :            : {
     736                 :          0 :     return _io_TextIOWrapper_isatty_impl(self);
     737                 :            : }
     738                 :            : 
     739                 :            : PyDoc_STRVAR(_io_TextIOWrapper_flush__doc__,
     740                 :            : "flush($self, /)\n"
     741                 :            : "--\n"
     742                 :            : "\n");
     743                 :            : 
     744                 :            : #define _IO_TEXTIOWRAPPER_FLUSH_METHODDEF    \
     745                 :            :     {"flush", (PyCFunction)_io_TextIOWrapper_flush, METH_NOARGS, _io_TextIOWrapper_flush__doc__},
     746                 :            : 
     747                 :            : static PyObject *
     748                 :            : _io_TextIOWrapper_flush_impl(textio *self);
     749                 :            : 
     750                 :            : static PyObject *
     751                 :        856 : _io_TextIOWrapper_flush(textio *self, PyObject *Py_UNUSED(ignored))
     752                 :            : {
     753                 :        856 :     return _io_TextIOWrapper_flush_impl(self);
     754                 :            : }
     755                 :            : 
     756                 :            : PyDoc_STRVAR(_io_TextIOWrapper_close__doc__,
     757                 :            : "close($self, /)\n"
     758                 :            : "--\n"
     759                 :            : "\n");
     760                 :            : 
     761                 :            : #define _IO_TEXTIOWRAPPER_CLOSE_METHODDEF    \
     762                 :            :     {"close", (PyCFunction)_io_TextIOWrapper_close, METH_NOARGS, _io_TextIOWrapper_close__doc__},
     763                 :            : 
     764                 :            : static PyObject *
     765                 :            : _io_TextIOWrapper_close_impl(textio *self);
     766                 :            : 
     767                 :            : static PyObject *
     768                 :        753 : _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
     769                 :            : {
     770                 :        753 :     return _io_TextIOWrapper_close_impl(self);
     771                 :            : }
     772                 :            : /*[clinic end generated code: output=73f84b13c343b34b input=a9049054013a1b77]*/

Generated by: LCOV version 1.14