Skip to content
Snippets Groups Projects
Select Git revision
  • db455296be5f792b8c12b7cd7f3962b52e4f44ee
  • main default protected
  • 3.10
  • 3.11
  • revert-15688-bpo-38031-_io-FileIO-opener-crash
  • 3.8
  • 3.9
  • 3.7
  • enum-fix_auto
  • branch-v3.11.0
  • backport-c3648f4-3.11
  • gh-93963/remove-importlib-resources-abcs
  • refactor-wait_for
  • shared-testcase
  • v3.12.0a2
  • v3.12.0a1
  • v3.11.0
  • v3.8.15
  • v3.9.15
  • v3.10.8
  • v3.7.15
  • v3.11.0rc2
  • v3.8.14
  • v3.9.14
  • v3.7.14
  • v3.10.7
  • v3.11.0rc1
  • v3.10.6
  • v3.11.0b5
  • v3.11.0b4
  • v3.10.5
  • v3.11.0b3
  • v3.11.0b2
  • v3.9.13
34 results

patchlevel.h

Blame
  • textio.c 97.99 KiB
    /*
        An implementation of Text I/O as defined by PEP 3116 - "New I/O"
    
        Classes defined here: TextIOBase, IncrementalNewlineDecoder, TextIOWrapper.
    
        Written by Amaury Forgeot d'Arc and Antoine Pitrou
    */
    
    #define PY_SSIZE_T_CLEAN
    #include "Python.h"
    #include "pycore_interp.h"        // PyInterpreterState.fs_codec
    #include "pycore_long.h"          // _PyLong_GetZero()
    #include "pycore_fileutils.h"     // _Py_GetLocaleEncoding()
    #include "pycore_object.h"
    #include "pycore_pystate.h"       // _PyInterpreterState_GET()
    #include "structmember.h"         // PyMemberDef
    #include "_iomodule.h"
    
    /*[clinic input]
    module _io
    class _io.IncrementalNewlineDecoder "nldecoder_object *" "&PyIncrementalNewlineDecoder_Type"
    class _io.TextIOWrapper "textio *" "&TextIOWrapper_Type"
    [clinic start generated code]*/
    /*[clinic end generated code: output=da39a3ee5e6b4b0d input=ed072384f8aada2c]*/
    
    /* TextIOBase */
    
    PyDoc_STRVAR(textiobase_doc,
        "Base class for text I/O.\n"
        "\n"
        "This class provides a character and line based interface to stream\n"
        "I/O. There is no readinto method because Python's character strings\n"
        "are immutable.\n"
        );
    
    static PyObject *
    _unsupported(const char *message)
    {
        _PyIO_State *state = IO_STATE();
        if (state != NULL)
            PyErr_SetString(state->unsupported_operation, message);
        return NULL;
    }
    
    PyDoc_STRVAR(textiobase_detach_doc,
        "Separate the underlying buffer from the TextIOBase and return it.\n"
        "\n"
        "After the underlying buffer has been detached, the TextIO is in an\n"
        "unusable state.\n"
        );
    
    static PyObject *
    textiobase_detach(PyObject *self, PyObject *Py_UNUSED(ignored))
    {
        return _unsupported("detach");
    }
    
    PyDoc_STRVAR(textiobase_read_doc,
        "Read at most n characters from stream.\n"
        "\n"
        "Read from underlying buffer until we have n characters or we hit EOF.\n"
        "If n is negative or omitted, read until EOF.\n"
        );
    
    static PyObject *
    textiobase_read(PyObject *self, PyObject *args)
    {
        return _unsupported("read");
    }