LCOV - code coverage report
Current view: top level - Modules/_io/clinic - iobase.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 17 63 27.0 %
Date: 2023-03-20 08:15:36 Functions: 5 12 41.7 %
Branches: 3 34 8.8 %

           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__IOBase_tell__doc__,
      12                 :            : "tell($self, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Return current stream position.");
      16                 :            : 
      17                 :            : #define _IO__IOBASE_TELL_METHODDEF    \
      18                 :            :     {"tell", (PyCFunction)_io__IOBase_tell, METH_NOARGS, _io__IOBase_tell__doc__},
      19                 :            : 
      20                 :            : static PyObject *
      21                 :            : _io__IOBase_tell_impl(PyObject *self);
      22                 :            : 
      23                 :            : static PyObject *
      24                 :          0 : _io__IOBase_tell(PyObject *self, PyObject *Py_UNUSED(ignored))
      25                 :            : {
      26                 :          0 :     return _io__IOBase_tell_impl(self);
      27                 :            : }
      28                 :            : 
      29                 :            : PyDoc_STRVAR(_io__IOBase_flush__doc__,
      30                 :            : "flush($self, /)\n"
      31                 :            : "--\n"
      32                 :            : "\n"
      33                 :            : "Flush write buffers, if applicable.\n"
      34                 :            : "\n"
      35                 :            : "This is not implemented for read-only and non-blocking streams.");
      36                 :            : 
      37                 :            : #define _IO__IOBASE_FLUSH_METHODDEF    \
      38                 :            :     {"flush", (PyCFunction)_io__IOBase_flush, METH_NOARGS, _io__IOBase_flush__doc__},
      39                 :            : 
      40                 :            : static PyObject *
      41                 :            : _io__IOBase_flush_impl(PyObject *self);
      42                 :            : 
      43                 :            : static PyObject *
      44                 :       3446 : _io__IOBase_flush(PyObject *self, PyObject *Py_UNUSED(ignored))
      45                 :            : {
      46                 :       3446 :     return _io__IOBase_flush_impl(self);
      47                 :            : }
      48                 :            : 
      49                 :            : PyDoc_STRVAR(_io__IOBase_close__doc__,
      50                 :            : "close($self, /)\n"
      51                 :            : "--\n"
      52                 :            : "\n"
      53                 :            : "Flush and close the IO object.\n"
      54                 :            : "\n"
      55                 :            : "This method has no effect if the file is already closed.");
      56                 :            : 
      57                 :            : #define _IO__IOBASE_CLOSE_METHODDEF    \
      58                 :            :     {"close", (PyCFunction)_io__IOBase_close, METH_NOARGS, _io__IOBase_close__doc__},
      59                 :            : 
      60                 :            : static PyObject *
      61                 :            : _io__IOBase_close_impl(PyObject *self);
      62                 :            : 
      63                 :            : static PyObject *
      64                 :       1500 : _io__IOBase_close(PyObject *self, PyObject *Py_UNUSED(ignored))
      65                 :            : {
      66                 :       1500 :     return _io__IOBase_close_impl(self);
      67                 :            : }
      68                 :            : 
      69                 :            : PyDoc_STRVAR(_io__IOBase_seekable__doc__,
      70                 :            : "seekable($self, /)\n"
      71                 :            : "--\n"
      72                 :            : "\n"
      73                 :            : "Return whether object supports random access.\n"
      74                 :            : "\n"
      75                 :            : "If False, seek(), tell() and truncate() will raise OSError.\n"
      76                 :            : "This method may need to do a test seek().");
      77                 :            : 
      78                 :            : #define _IO__IOBASE_SEEKABLE_METHODDEF    \
      79                 :            :     {"seekable", (PyCFunction)_io__IOBase_seekable, METH_NOARGS, _io__IOBase_seekable__doc__},
      80                 :            : 
      81                 :            : static PyObject *
      82                 :            : _io__IOBase_seekable_impl(PyObject *self);
      83                 :            : 
      84                 :            : static PyObject *
      85                 :          0 : _io__IOBase_seekable(PyObject *self, PyObject *Py_UNUSED(ignored))
      86                 :            : {
      87                 :          0 :     return _io__IOBase_seekable_impl(self);
      88                 :            : }
      89                 :            : 
      90                 :            : PyDoc_STRVAR(_io__IOBase_readable__doc__,
      91                 :            : "readable($self, /)\n"
      92                 :            : "--\n"
      93                 :            : "\n"
      94                 :            : "Return whether object was opened for reading.\n"
      95                 :            : "\n"
      96                 :            : "If False, read() will raise OSError.");
      97                 :            : 
      98                 :            : #define _IO__IOBASE_READABLE_METHODDEF    \
      99                 :            :     {"readable", (PyCFunction)_io__IOBase_readable, METH_NOARGS, _io__IOBase_readable__doc__},
     100                 :            : 
     101                 :            : static PyObject *
     102                 :            : _io__IOBase_readable_impl(PyObject *self);
     103                 :            : 
     104                 :            : static PyObject *
     105                 :         74 : _io__IOBase_readable(PyObject *self, PyObject *Py_UNUSED(ignored))
     106                 :            : {
     107                 :         74 :     return _io__IOBase_readable_impl(self);
     108                 :            : }
     109                 :            : 
     110                 :            : PyDoc_STRVAR(_io__IOBase_writable__doc__,
     111                 :            : "writable($self, /)\n"
     112                 :            : "--\n"
     113                 :            : "\n"
     114                 :            : "Return whether object was opened for writing.\n"
     115                 :            : "\n"
     116                 :            : "If False, write() will raise OSError.");
     117                 :            : 
     118                 :            : #define _IO__IOBASE_WRITABLE_METHODDEF    \
     119                 :            :     {"writable", (PyCFunction)_io__IOBase_writable, METH_NOARGS, _io__IOBase_writable__doc__},
     120                 :            : 
     121                 :            : static PyObject *
     122                 :            : _io__IOBase_writable_impl(PyObject *self);
     123                 :            : 
     124                 :            : static PyObject *
     125                 :        679 : _io__IOBase_writable(PyObject *self, PyObject *Py_UNUSED(ignored))
     126                 :            : {
     127                 :        679 :     return _io__IOBase_writable_impl(self);
     128                 :            : }
     129                 :            : 
     130                 :            : PyDoc_STRVAR(_io__IOBase_fileno__doc__,
     131                 :            : "fileno($self, /)\n"
     132                 :            : "--\n"
     133                 :            : "\n"
     134                 :            : "Returns underlying file descriptor if one exists.\n"
     135                 :            : "\n"
     136                 :            : "OSError is raised if the IO object does not use a file descriptor.");
     137                 :            : 
     138                 :            : #define _IO__IOBASE_FILENO_METHODDEF    \
     139                 :            :     {"fileno", (PyCFunction)_io__IOBase_fileno, METH_NOARGS, _io__IOBase_fileno__doc__},
     140                 :            : 
     141                 :            : static PyObject *
     142                 :            : _io__IOBase_fileno_impl(PyObject *self);
     143                 :            : 
     144                 :            : static PyObject *
     145                 :          0 : _io__IOBase_fileno(PyObject *self, PyObject *Py_UNUSED(ignored))
     146                 :            : {
     147                 :          0 :     return _io__IOBase_fileno_impl(self);
     148                 :            : }
     149                 :            : 
     150                 :            : PyDoc_STRVAR(_io__IOBase_isatty__doc__,
     151                 :            : "isatty($self, /)\n"
     152                 :            : "--\n"
     153                 :            : "\n"
     154                 :            : "Return whether this is an \'interactive\' stream.\n"
     155                 :            : "\n"
     156                 :            : "Return False if it can\'t be determined.");
     157                 :            : 
     158                 :            : #define _IO__IOBASE_ISATTY_METHODDEF    \
     159                 :            :     {"isatty", (PyCFunction)_io__IOBase_isatty, METH_NOARGS, _io__IOBase_isatty__doc__},
     160                 :            : 
     161                 :            : static PyObject *
     162                 :            : _io__IOBase_isatty_impl(PyObject *self);
     163                 :            : 
     164                 :            : static PyObject *
     165                 :          0 : _io__IOBase_isatty(PyObject *self, PyObject *Py_UNUSED(ignored))
     166                 :            : {
     167                 :          0 :     return _io__IOBase_isatty_impl(self);
     168                 :            : }
     169                 :            : 
     170                 :            : PyDoc_STRVAR(_io__IOBase_readline__doc__,
     171                 :            : "readline($self, size=-1, /)\n"
     172                 :            : "--\n"
     173                 :            : "\n"
     174                 :            : "Read and return a line from the stream.\n"
     175                 :            : "\n"
     176                 :            : "If size is specified, at most size bytes will be read.\n"
     177                 :            : "\n"
     178                 :            : "The line terminator is always b\'\\n\' for binary files; for text\n"
     179                 :            : "files, the newlines argument to open can be used to select the line\n"
     180                 :            : "terminator(s) recognized.");
     181                 :            : 
     182                 :            : #define _IO__IOBASE_READLINE_METHODDEF    \
     183                 :            :     {"readline", _PyCFunction_CAST(_io__IOBase_readline), METH_FASTCALL, _io__IOBase_readline__doc__},
     184                 :            : 
     185                 :            : static PyObject *
     186                 :            : _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit);
     187                 :            : 
     188                 :            : static PyObject *
     189                 :          0 : _io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     190                 :            : {
     191                 :          0 :     PyObject *return_value = NULL;
     192                 :          0 :     Py_ssize_t limit = -1;
     193                 :            : 
     194   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
                   #  # ]
     195                 :          0 :         goto exit;
     196                 :            :     }
     197         [ #  # ]:          0 :     if (nargs < 1) {
     198                 :          0 :         goto skip_optional;
     199                 :            :     }
     200         [ #  # ]:          0 :     if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) {
     201                 :          0 :         goto exit;
     202                 :            :     }
     203                 :          0 : skip_optional:
     204                 :          0 :     return_value = _io__IOBase_readline_impl(self, limit);
     205                 :            : 
     206                 :          0 : exit:
     207                 :          0 :     return return_value;
     208                 :            : }
     209                 :            : 
     210                 :            : PyDoc_STRVAR(_io__IOBase_readlines__doc__,
     211                 :            : "readlines($self, hint=-1, /)\n"
     212                 :            : "--\n"
     213                 :            : "\n"
     214                 :            : "Return a list of lines from the stream.\n"
     215                 :            : "\n"
     216                 :            : "hint can be specified to control the number of lines read: no more\n"
     217                 :            : "lines will be read if the total size (in bytes/characters) of all\n"
     218                 :            : "lines so far exceeds hint.");
     219                 :            : 
     220                 :            : #define _IO__IOBASE_READLINES_METHODDEF    \
     221                 :            :     {"readlines", _PyCFunction_CAST(_io__IOBase_readlines), METH_FASTCALL, _io__IOBase_readlines__doc__},
     222                 :            : 
     223                 :            : static PyObject *
     224                 :            : _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint);
     225                 :            : 
     226                 :            : static PyObject *
     227                 :          2 : _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     228                 :            : {
     229                 :          2 :     PyObject *return_value = NULL;
     230                 :          2 :     Py_ssize_t hint = -1;
     231                 :            : 
     232   [ +  -  -  +  :          2 :     if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
                   -  - ]
     233                 :          0 :         goto exit;
     234                 :            :     }
     235         [ +  - ]:          2 :     if (nargs < 1) {
     236                 :          2 :         goto skip_optional;
     237                 :            :     }
     238         [ #  # ]:          0 :     if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) {
     239                 :          0 :         goto exit;
     240                 :            :     }
     241                 :          0 : skip_optional:
     242                 :          2 :     return_value = _io__IOBase_readlines_impl(self, hint);
     243                 :            : 
     244                 :          2 : exit:
     245                 :          2 :     return return_value;
     246                 :            : }
     247                 :            : 
     248                 :            : PyDoc_STRVAR(_io__IOBase_writelines__doc__,
     249                 :            : "writelines($self, lines, /)\n"
     250                 :            : "--\n"
     251                 :            : "\n"
     252                 :            : "Write a list of lines to stream.\n"
     253                 :            : "\n"
     254                 :            : "Line separators are not added, so it is usual for each of the\n"
     255                 :            : "lines provided to have a line separator at the end.");
     256                 :            : 
     257                 :            : #define _IO__IOBASE_WRITELINES_METHODDEF    \
     258                 :            :     {"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__},
     259                 :            : 
     260                 :            : PyDoc_STRVAR(_io__RawIOBase_read__doc__,
     261                 :            : "read($self, size=-1, /)\n"
     262                 :            : "--\n"
     263                 :            : "\n");
     264                 :            : 
     265                 :            : #define _IO__RAWIOBASE_READ_METHODDEF    \
     266                 :            :     {"read", _PyCFunction_CAST(_io__RawIOBase_read), METH_FASTCALL, _io__RawIOBase_read__doc__},
     267                 :            : 
     268                 :            : static PyObject *
     269                 :            : _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n);
     270                 :            : 
     271                 :            : static PyObject *
     272                 :          0 : _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
     273                 :            : {
     274                 :          0 :     PyObject *return_value = NULL;
     275                 :          0 :     Py_ssize_t n = -1;
     276                 :            : 
     277   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
                   #  # ]
     278                 :          0 :         goto exit;
     279                 :            :     }
     280         [ #  # ]:          0 :     if (nargs < 1) {
     281                 :          0 :         goto skip_optional;
     282                 :            :     }
     283                 :            :     {
     284                 :          0 :         Py_ssize_t ival = -1;
     285                 :          0 :         PyObject *iobj = _PyNumber_Index(args[0]);
     286         [ #  # ]:          0 :         if (iobj != NULL) {
     287                 :          0 :             ival = PyLong_AsSsize_t(iobj);
     288                 :          0 :             Py_DECREF(iobj);
     289                 :            :         }
     290   [ #  #  #  # ]:          0 :         if (ival == -1 && PyErr_Occurred()) {
     291                 :          0 :             goto exit;
     292                 :            :         }
     293                 :          0 :         n = ival;
     294                 :            :     }
     295                 :          0 : skip_optional:
     296                 :          0 :     return_value = _io__RawIOBase_read_impl(self, n);
     297                 :            : 
     298                 :          0 : exit:
     299                 :          0 :     return return_value;
     300                 :            : }
     301                 :            : 
     302                 :            : PyDoc_STRVAR(_io__RawIOBase_readall__doc__,
     303                 :            : "readall($self, /)\n"
     304                 :            : "--\n"
     305                 :            : "\n"
     306                 :            : "Read until EOF, using multiple read() call.");
     307                 :            : 
     308                 :            : #define _IO__RAWIOBASE_READALL_METHODDEF    \
     309                 :            :     {"readall", (PyCFunction)_io__RawIOBase_readall, METH_NOARGS, _io__RawIOBase_readall__doc__},
     310                 :            : 
     311                 :            : static PyObject *
     312                 :            : _io__RawIOBase_readall_impl(PyObject *self);
     313                 :            : 
     314                 :            : static PyObject *
     315                 :          0 : _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
     316                 :            : {
     317                 :          0 :     return _io__RawIOBase_readall_impl(self);
     318                 :            : }
     319                 :            : /*[clinic end generated code: output=b7246a2087eb966b input=a9049054013a1b77]*/

Generated by: LCOV version 1.14