5
5
6
6
/*[clinic input]
7
7
module _io
8
- class _io.BytesIO "bytesio *" "& PyBytesIO_Type"
8
+ class _io.BytesIO "bytesio *" "clinic_state()-> PyBytesIO_Type"
9
9
[clinic start generated code]*/
10
10
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7f50ec034f5c0b26]*/
11
11
@@ -881,6 +881,7 @@ bytesio_setstate(bytesio *self, PyObject *state)
881
881
static void
882
882
bytesio_dealloc (bytesio * self )
883
883
{
884
+ PyTypeObject * tp = Py_TYPE (self );
884
885
_PyObject_GC_UNTRACK (self );
885
886
if (self -> exports > 0 ) {
886
887
PyErr_SetString (PyExc_SystemError ,
@@ -891,7 +892,8 @@ bytesio_dealloc(bytesio *self)
891
892
Py_CLEAR (self -> dict );
892
893
if (self -> weakreflist != NULL )
893
894
PyObject_ClearWeakRefs ((PyObject * ) self );
894
- Py_TYPE (self )-> tp_free (self );
895
+ tp -> tp_free (self );
896
+ Py_DECREF (tp );
895
897
}
896
898
897
899
static PyObject *
@@ -971,6 +973,7 @@ bytesio_sizeof(bytesio *self, void *unused)
971
973
static int
972
974
bytesio_traverse (bytesio * self , visitproc visit , void * arg )
973
975
{
976
+ Py_VISIT (Py_TYPE (self ));
974
977
Py_VISIT (self -> dict );
975
978
return 0 ;
976
979
}
@@ -983,7 +986,9 @@ bytesio_clear(bytesio *self)
983
986
}
984
987
985
988
989
+ #define clinic_state () (IO_STATE())
986
990
#include "clinic/bytesio.c.h"
991
+ #undef clinic_state
987
992
988
993
static PyGetSetDef bytesio_getsetlist [] = {
989
994
{"closed" , (getter )bytesio_get_closed , NULL ,
@@ -1016,48 +1021,34 @@ static struct PyMethodDef bytesio_methods[] = {
1016
1021
{NULL , NULL } /* sentinel */
1017
1022
};
1018
1023
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 }
1059
1028
};
1060
1029
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
+ };
1061
1052
1062
1053
/*
1063
1054
* Implementation of the small intermediate object used by getbuffer().
0 commit comments