20
20
module _io
21
21
class _io.IncrementalNewlineDecoder "nldecoder_object *" "clinic_state()->PyIncrementalNewlineDecoder_Type"
22
22
class _io.TextIOWrapper "textio *" "clinic_state()->TextIOWrapper_Type"
23
+ class _io._TextIOBase "PyObject *" "&PyTextIOBase_Type"
23
24
[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
25
33
26
34
/* TextIOBase */
27
35
@@ -42,52 +50,76 @@ _unsupported(const char *message)
42
50
return NULL ;
43
51
}
44
52
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]*/
51
62
52
63
static 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]*/
54
66
{
55
67
return _unsupported ("detach" );
56
68
}
57
69
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]*/
64
81
65
82
static 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]*/
67
85
{
68
86
return _unsupported ("read" );
69
87
}
70
88
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]*/
76
99
77
100
static 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]*/
79
104
{
80
105
return _unsupported ("readline" );
81
106
}
82
107
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]*/
88
119
89
120
static 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]*/
91
123
{
92
124
return _unsupported ("write" );
93
125
}
@@ -132,10 +164,10 @@ textiobase_errors_get(PyObject *self, void *context)
132
164
133
165
134
166
static 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
139
171
{NULL , NULL }
140
172
};
141
173
@@ -200,14 +232,14 @@ PyTypeObject PyTextIOBase_Type = {
200
232
201
233
/* IncrementalNewlineDecoder */
202
234
203
- typedef struct {
235
+ struct nldecoder_object {
204
236
PyObject_HEAD
205
237
PyObject * decoder ;
206
238
PyObject * errors ;
207
239
unsigned int pendingcr : 1 ;
208
240
unsigned int translate : 1 ;
209
241
unsigned int seennl : 3 ;
210
- } nldecoder_object ;
242
+ };
211
243
212
244
/*[clinic input]
213
245
_io.IncrementalNewlineDecoder.__init__
@@ -645,7 +677,7 @@ incrementalnewlinedecoder_newlines_get(nldecoder_object *self, void *context)
645
677
typedef PyObject *
646
678
(* encodefunc_t )(PyObject * , PyObject * );
647
679
648
- typedef struct
680
+ struct textio
649
681
{
650
682
PyObject_HEAD
651
683
int ok ; /* initialized? */
@@ -704,7 +736,7 @@ typedef struct
704
736
PyObject * dict ;
705
737
706
738
_PyIO_State * state ;
707
- } textio ;
739
+ };
708
740
709
741
static void
710
742
textiowrapper_set_decoded_chars (textio * self , PyObject * chars );
@@ -3179,10 +3211,6 @@ textiowrapper_chunk_size_set(textio *self, PyObject *arg, void *context)
3179
3211
return 0 ;
3180
3212
}
3181
3213
3182
- #define clinic_state () (find_io_state_by_def(Py_TYPE(self)))
3183
- #include "clinic/textio.c.h"
3184
- #undef clinic_state
3185
-
3186
3214
static PyMethodDef incrementalnewlinedecoder_methods [] = {
3187
3215
_IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF
3188
3216
_IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF
0 commit comments