55
66/*[clinic input]
77module _io
8- class _io.BytesIO "bytesio *" "& PyBytesIO_Type"
8+ class _io.BytesIO "bytesio *" "clinic_state()-> PyBytesIO_Type"
99[clinic start generated code]*/
1010/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7f50ec034f5c0b26]*/
1111
@@ -881,6 +881,7 @@ bytesio_setstate(bytesio *self, PyObject *state)
881881static void
882882bytesio_dealloc (bytesio * self )
883883{
884+ PyTypeObject * tp = Py_TYPE (self );
884885 _PyObject_GC_UNTRACK (self );
885886 if (self -> exports > 0 ) {
886887 PyErr_SetString (PyExc_SystemError ,
@@ -891,7 +892,8 @@ bytesio_dealloc(bytesio *self)
891892 Py_CLEAR (self -> dict );
892893 if (self -> weakreflist != NULL )
893894 PyObject_ClearWeakRefs ((PyObject * ) self );
894- Py_TYPE (self )-> tp_free (self );
895+ tp -> tp_free (self );
896+ Py_DECREF (tp );
895897}
896898
897899static PyObject *
@@ -971,6 +973,7 @@ bytesio_sizeof(bytesio *self, void *unused)
971973static int
972974bytesio_traverse (bytesio * self , visitproc visit , void * arg )
973975{
976+ Py_VISIT (Py_TYPE (self ));
974977 Py_VISIT (self -> dict );
975978 return 0 ;
976979}
@@ -983,7 +986,9 @@ bytesio_clear(bytesio *self)
983986}
984987
985988
989+ #define clinic_state () (IO_STATE())
986990#include "clinic/bytesio.c.h"
991+ #undef clinic_state
987992
988993static PyGetSetDef bytesio_getsetlist [] = {
989994 {"closed" , (getter )bytesio_get_closed , NULL ,
@@ -1016,48 +1021,34 @@ static struct PyMethodDef bytesio_methods[] = {
10161021 {NULL , NULL } /* sentinel */
10171022};
10181023
1019- PyTypeObject PyBytesIO_Type = {
1020- PyVarObject_HEAD_INIT (NULL , 0 )
1021- "_io.BytesIO" , /*tp_name*/
1022- sizeof (bytesio ), /*tp_basicsize*/
1023- 0 , /*tp_itemsize*/
1024- (destructor )bytesio_dealloc , /*tp_dealloc*/
1025- 0 , /*tp_vectorcall_offset*/
1026- 0 , /*tp_getattr*/
1027- 0 , /*tp_setattr*/
1028- 0 , /*tp_as_async*/
1029- 0 , /*tp_repr*/
1030- 0 , /*tp_as_number*/
1031- 0 , /*tp_as_sequence*/
1032- 0 , /*tp_as_mapping*/
1033- 0 , /*tp_hash*/
1034- 0 , /*tp_call*/
1035- 0 , /*tp_str*/
1036- 0 , /*tp_getattro*/
1037- 0 , /*tp_setattro*/
1038- 0 , /*tp_as_buffer*/
1039- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
1040- Py_TPFLAGS_HAVE_GC , /*tp_flags*/
1041- _io_BytesIO___init____doc__ , /*tp_doc*/
1042- (traverseproc )bytesio_traverse , /*tp_traverse*/
1043- (inquiry )bytesio_clear , /*tp_clear*/
1044- 0 , /*tp_richcompare*/
1045- offsetof(bytesio , weakreflist ), /*tp_weaklistoffset*/
1046- PyObject_SelfIter , /*tp_iter*/
1047- (iternextfunc )bytesio_iternext , /*tp_iternext*/
1048- bytesio_methods , /*tp_methods*/
1049- 0 , /*tp_members*/
1050- bytesio_getsetlist , /*tp_getset*/
1051- 0 , /*tp_base*/
1052- 0 , /*tp_dict*/
1053- 0 , /*tp_descr_get*/
1054- 0 , /*tp_descr_set*/
1055- offsetof(bytesio , dict ), /*tp_dictoffset*/
1056- _io_BytesIO___init__ , /*tp_init*/
1057- 0 , /*tp_alloc*/
1058- bytesio_new , /*tp_new*/
1024+ static PyMemberDef bytesio_members [] = {
1025+ {"__weaklistoffset__" , T_PYSSIZET , offsetof(bytesio , weakreflist ), READONLY },
1026+ {"__dictoffset__" , T_PYSSIZET , offsetof(bytesio , dict ), READONLY },
1027+ {NULL }
10591028};
10601029
1030+ static PyType_Slot bytesio_slots [] = {
1031+ {Py_tp_dealloc , bytesio_dealloc },
1032+ {Py_tp_doc , (void * )_io_BytesIO___init____doc__ },
1033+ {Py_tp_traverse , bytesio_traverse },
1034+ {Py_tp_clear , bytesio_clear },
1035+ {Py_tp_iter , PyObject_SelfIter },
1036+ {Py_tp_iternext , bytesio_iternext },
1037+ {Py_tp_methods , bytesio_methods },
1038+ {Py_tp_members , bytesio_members },
1039+ {Py_tp_getset , bytesio_getsetlist },
1040+ {Py_tp_init , _io_BytesIO___init__ },
1041+ {Py_tp_new , bytesio_new },
1042+ {0 , NULL },
1043+ };
1044+
1045+ PyType_Spec bytesio_spec = {
1046+ .name = "_io.BytesIO" ,
1047+ .basicsize = sizeof (bytesio ),
1048+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
1049+ Py_TPFLAGS_IMMUTABLETYPE ),
1050+ .slots = bytesio_slots ,
1051+ };
10611052
10621053/*
10631054 * Implementation of the small intermediate object used by getbuffer().
0 commit comments