@@ -137,9 +137,9 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
137
137
138
138
/*[clinic input]
139
139
module _io
140
- class _io._WindowsConsoleIO "winconsoleio *" "& PyWindowsConsoleIO_Type"
140
+ class _io._WindowsConsoleIO "winconsoleio *" "clinic_state()-> PyWindowsConsoleIO_Type"
141
141
[clinic start generated code]*/
142
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e897fdc1fba4e131 ]*/
142
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=05526e723011ab36 ]*/
143
143
144
144
typedef struct {
145
145
PyObject_HEAD
@@ -156,8 +156,6 @@ typedef struct {
156
156
wchar_t wbuf ;
157
157
} winconsoleio ;
158
158
159
- PyTypeObject PyWindowsConsoleIO_Type ;
160
-
161
159
int
162
160
_PyWindowsConsoleIO_closed (PyObject * self )
163
161
{
@@ -265,7 +263,10 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
265
263
int fd_is_own = 0 ;
266
264
HANDLE handle = NULL ;
267
265
268
- assert (PyObject_TypeCheck (self , (PyTypeObject * )& PyWindowsConsoleIO_Type ));
266
+ #ifdef Py_DEBUG
267
+ _PyIO_State * state = find_io_state_by_def (Py_TYPE (self ));
268
+ assert (PyObject_TypeCheck (self , state -> PyWindowsConsoleIO_Type ));
269
+ #endif
269
270
if (self -> fd >= 0 ) {
270
271
if (self -> closefd ) {
271
272
/* Have to close the existing file first. */
@@ -417,6 +418,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
417
418
static int
418
419
winconsoleio_traverse (winconsoleio * self , visitproc visit , void * arg )
419
420
{
421
+ Py_VISIT (Py_TYPE (self ));
420
422
Py_VISIT (self -> dict );
421
423
return 0 ;
422
424
}
@@ -431,14 +433,16 @@ winconsoleio_clear(winconsoleio *self)
431
433
static void
432
434
winconsoleio_dealloc (winconsoleio * self )
433
435
{
436
+ PyTypeObject * tp = Py_TYPE (self );
434
437
self -> finalizing = 1 ;
435
438
if (_PyIOBase_finalize ((PyObject * ) self ) < 0 )
436
439
return ;
437
440
_PyObject_GC_UNTRACK (self );
438
441
if (self -> weakreflist != NULL )
439
442
PyObject_ClearWeakRefs ((PyObject * ) self );
440
443
Py_CLEAR (self -> dict );
441
- Py_TYPE (self )-> tp_free ((PyObject * )self );
444
+ tp -> tp_free ((PyObject * )self );
445
+ Py_DECREF (tp );
442
446
}
443
447
444
448
static PyObject *
@@ -1078,7 +1082,9 @@ _io__WindowsConsoleIO_isatty_impl(winconsoleio *self)
1078
1082
Py_RETURN_TRUE ;
1079
1083
}
1080
1084
1085
+ #define clinic_state () (IO_STATE())
1081
1086
#include "clinic/winconsoleio.c.h"
1087
+ #undef clinic_state
1082
1088
1083
1089
static PyMethodDef winconsoleio_methods [] = {
1084
1090
_IO__WINDOWSCONSOLEIO_READ_METHODDEF
@@ -1124,59 +1130,32 @@ static PyGetSetDef winconsoleio_getsetlist[] = {
1124
1130
static PyMemberDef winconsoleio_members [] = {
1125
1131
{"_blksize" , T_UINT , offsetof(winconsoleio , blksize ), 0 },
1126
1132
{"_finalizing" , T_BOOL , offsetof(winconsoleio , finalizing ), 0 },
1133
+ {"__weaklistoffset__" , T_PYSSIZET , offsetof(winconsoleio , weakreflist ), READONLY },
1134
+ {"__dictoffset__" , T_PYSSIZET , offsetof(winconsoleio , dict ), READONLY },
1127
1135
{NULL }
1128
1136
};
1129
1137
1130
- PyTypeObject PyWindowsConsoleIO_Type = {
1131
- PyVarObject_HEAD_INIT (NULL , 0 )
1132
- "_io._WindowsConsoleIO" ,
1133
- sizeof (winconsoleio ),
1134
- 0 ,
1135
- (destructor )winconsoleio_dealloc , /* tp_dealloc */
1136
- 0 , /* tp_vectorcall_offset */
1137
- 0 , /* tp_getattr */
1138
- 0 , /* tp_setattr */
1139
- 0 , /* tp_as_async */
1140
- (reprfunc )winconsoleio_repr , /* tp_repr */
1141
- 0 , /* tp_as_number */
1142
- 0 , /* tp_as_sequence */
1143
- 0 , /* tp_as_mapping */
1144
- 0 , /* tp_hash */
1145
- 0 , /* tp_call */
1146
- 0 , /* tp_str */
1147
- PyObject_GenericGetAttr , /* tp_getattro */
1148
- 0 , /* tp_setattro */
1149
- 0 , /* tp_as_buffer */
1150
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
1151
- | Py_TPFLAGS_HAVE_GC , /* tp_flags */
1152
- _io__WindowsConsoleIO___init____doc__ , /* tp_doc */
1153
- (traverseproc )winconsoleio_traverse , /* tp_traverse */
1154
- (inquiry )winconsoleio_clear , /* tp_clear */
1155
- 0 , /* tp_richcompare */
1156
- offsetof(winconsoleio , weakreflist ), /* tp_weaklistoffset */
1157
- 0 , /* tp_iter */
1158
- 0 , /* tp_iternext */
1159
- winconsoleio_methods , /* tp_methods */
1160
- winconsoleio_members , /* tp_members */
1161
- winconsoleio_getsetlist , /* tp_getset */
1162
- 0 , /* tp_base */
1163
- 0 , /* tp_dict */
1164
- 0 , /* tp_descr_get */
1165
- 0 , /* tp_descr_set */
1166
- offsetof(winconsoleio , dict ), /* tp_dictoffset */
1167
- _io__WindowsConsoleIO___init__ , /* tp_init */
1168
- PyType_GenericAlloc , /* tp_alloc */
1169
- winconsoleio_new , /* tp_new */
1170
- PyObject_GC_Del , /* tp_free */
1171
- 0 , /* tp_is_gc */
1172
- 0 , /* tp_bases */
1173
- 0 , /* tp_mro */
1174
- 0 , /* tp_cache */
1175
- 0 , /* tp_subclasses */
1176
- 0 , /* tp_weaklist */
1177
- 0 , /* tp_del */
1178
- 0 , /* tp_version_tag */
1179
- 0 , /* tp_finalize */
1138
+ static PyType_Slot winconsoleio_slots [] = {
1139
+ {Py_tp_dealloc , winconsoleio_dealloc },
1140
+ {Py_tp_repr , winconsoleio_repr },
1141
+ {Py_tp_getattro , PyObject_GenericGetAttr },
1142
+ {Py_tp_doc , (void * )_io__WindowsConsoleIO___init____doc__ },
1143
+ {Py_tp_traverse , winconsoleio_traverse },
1144
+ {Py_tp_clear , winconsoleio_clear },
1145
+ {Py_tp_methods , winconsoleio_methods },
1146
+ {Py_tp_members , winconsoleio_members },
1147
+ {Py_tp_getset , winconsoleio_getsetlist },
1148
+ {Py_tp_init , _io__WindowsConsoleIO___init__ },
1149
+ {Py_tp_new , winconsoleio_new },
1150
+ {0 , NULL },
1151
+ };
1152
+
1153
+ PyType_Spec winconsoleio_spec = {
1154
+ .name = "_io._WindowsConsoleIO" ,
1155
+ .basicsize = sizeof (winconsoleio ),
1156
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
1157
+ Py_TPFLAGS_IMMUTABLETYPE ),
1158
+ .slots = winconsoleio_slots ,
1180
1159
};
1181
1160
1182
1161
#endif /* HAVE_WINDOWS_CONSOLE_IO */
0 commit comments