2020module _io
2121class _io.IncrementalNewlineDecoder "nldecoder_object *" "clinic_state()->PyIncrementalNewlineDecoder_Type"
2222class _io.TextIOWrapper "textio *" "clinic_state()->TextIOWrapper_Type"
23+ class _io._TextIOBase "PyObject *" "&PyTextIOBase_Type"
2324[clinic start generated code]*/
24- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=81f67cf54eaa6001]*/
25+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=8b7f24fa13bfdd7f]*/
26+
27+ typedef struct nldecoder_object nldecoder_object ;
28+ typedef struct textio textio ;
29+
30+ #define clinic_state () (find_io_state_by_def(Py_TYPE(self)))
31+ #include "clinic/textio.c.h"
32+ #undef clinic_state
2533
2634/* TextIOBase */
2735
@@ -42,52 +50,76 @@ _unsupported(const char *message)
4250 return NULL ;
4351}
4452
45- PyDoc_STRVAR (textiobase_detach_doc ,
46- "Separate the underlying buffer from the TextIOBase and return it.\n"
47- "\n"
48- "After the underlying buffer has been detached, the TextIO is in an\n"
49- "unusable state.\n"
50- );
53+ /*[clinic input]
54+ _io._TextIOBase.detach
55+ cls: defining_class
56+ /
57+
58+ Separate the underlying buffer from the TextIOBase and return it.
59+
60+ After the underlying buffer has been detached, the TextIO is in an unusable state.
61+ [clinic start generated code]*/
5162
5263static PyObject *
53- textiobase_detach (PyObject * self , PyObject * Py_UNUSED (ignored ))
64+ _io__TextIOBase_detach_impl (PyObject * self , PyTypeObject * cls )
65+ /*[clinic end generated code: output=50915f40c609eaa4 input=987ca3640d0a3776]*/
5466{
5567 return _unsupported ("detach" );
5668}
5769
58- PyDoc_STRVAR (textiobase_read_doc ,
59- "Read at most size characters from stream.\n"
60- "\n"
61- "Read from underlying buffer until we have size characters or we hit EOF.\n"
62- "If size is negative or omitted, read until EOF.\n"
63- );
70+ /*[clinic input]
71+ _io._TextIOBase.read
72+ cls: defining_class
73+ /
74+ *args: object
75+
76+ Read at most size characters from stream.
77+
78+ Read from underlying buffer until we have size characters or we hit EOF.
79+ If size is negative or omitted, read until EOF.
80+ [clinic start generated code]*/
6481
6582static PyObject *
66- textiobase_read (PyObject * self , PyObject * args )
83+ _io__TextIOBase_read_impl (PyObject * self , PyTypeObject * cls , PyObject * args )
84+ /*[clinic end generated code: output=3adf28998831f461 input=cee1e84664a20de0]*/
6785{
6886 return _unsupported ("read" );
6987}
7088
71- PyDoc_STRVAR (textiobase_readline_doc ,
72- "Read until newline or EOF.\n"
73- "\n"
74- "Returns an empty string if EOF is hit immediately.\n"
75- );
89+ /*[clinic input]
90+ _io._TextIOBase.readline
91+ cls: defining_class
92+ /
93+ *args: object
94+
95+ Read until newline or EOF.
96+
97+ Return an empty string if EOF is hit immediately.
98+ [clinic start generated code]*/
7699
77100static PyObject *
78- textiobase_readline (PyObject * self , PyObject * args )
101+ _io__TextIOBase_readline_impl (PyObject * self , PyTypeObject * cls ,
102+ PyObject * args )
103+ /*[clinic end generated code: output=3073a948d02319f3 input=58f801259f7ff3ef]*/
79104{
80105 return _unsupported ("readline" );
81106}
82107
83- PyDoc_STRVAR (textiobase_write_doc ,
84- "Write string to stream.\n"
85- "Returns the number of characters written (which is always equal to\n"
86- "the length of the string).\n"
87- );
108+ /*[clinic input]
109+ _io._TextIOBase.write
110+ cls: defining_class
111+ /
112+ *args: object
113+
114+ Write string to stream.
115+
116+ Return the number of characters written
117+ (which is always equal to the length of the string).
118+ [clinic start generated code]*/
88119
89120static PyObject *
90- textiobase_write (PyObject * self , PyObject * args )
121+ _io__TextIOBase_write_impl (PyObject * self , PyTypeObject * cls , PyObject * args )
122+ /*[clinic end generated code: output=5d985eb529472bc4 input=21b6961b5cba9496]*/
91123{
92124 return _unsupported ("write" );
93125}
@@ -132,10 +164,10 @@ textiobase_errors_get(PyObject *self, void *context)
132164
133165
134166static PyMethodDef textiobase_methods [] = {
135- { "detach" , textiobase_detach , METH_NOARGS , textiobase_detach_doc },
136- { "read" , textiobase_read , METH_VARARGS , textiobase_read_doc },
137- { "readline" , textiobase_readline , METH_VARARGS , textiobase_readline_doc },
138- { "write" , textiobase_write , METH_VARARGS , textiobase_write_doc },
167+ _IO__TEXTIOBASE_DETACH_METHODDEF
168+ _IO__TEXTIOBASE_READ_METHODDEF
169+ _IO__TEXTIOBASE_READLINE_METHODDEF
170+ _IO__TEXTIOBASE_WRITE_METHODDEF
139171 {NULL , NULL }
140172};
141173
@@ -200,14 +232,14 @@ PyTypeObject PyTextIOBase_Type = {
200232
201233/* IncrementalNewlineDecoder */
202234
203- typedef struct {
235+ struct nldecoder_object {
204236 PyObject_HEAD
205237 PyObject * decoder ;
206238 PyObject * errors ;
207239 unsigned int pendingcr : 1 ;
208240 unsigned int translate : 1 ;
209241 unsigned int seennl : 3 ;
210- } nldecoder_object ;
242+ };
211243
212244/*[clinic input]
213245_io.IncrementalNewlineDecoder.__init__
@@ -645,7 +677,7 @@ incrementalnewlinedecoder_newlines_get(nldecoder_object *self, void *context)
645677typedef PyObject *
646678 (* encodefunc_t )(PyObject * , PyObject * );
647679
648- typedef struct
680+ struct textio
649681{
650682 PyObject_HEAD
651683 int ok ; /* initialized? */
@@ -704,7 +736,7 @@ typedef struct
704736 PyObject * dict ;
705737
706738 _PyIO_State * state ;
707- } textio ;
739+ };
708740
709741static void
710742textiowrapper_set_decoded_chars (textio * self , PyObject * chars );
@@ -3179,10 +3211,6 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context)
31793211 return 0 ;
31803212}
31813213
3182- #define clinic_state () (find_io_state_by_def(Py_TYPE(self)))
3183- #include "clinic/textio.c.h"
3184- #undef clinic_state
3185-
31863214static PyMethodDef incrementalnewlinedecoder_methods [] = {
31873215 _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF
31883216 _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF
0 commit comments