FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-101819: Port _io.PyIncrementalNewlineDecoder_Type to heap type by erlend-aasland · Pull Request #104249 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .h  (1) .tsv  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 1 addition & 2 deletions Modules/_io/_iomodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ struct PyModuleDef _PyIO_Module = {
static PyTypeObject* static_types[] = {
// Base classes
&PyIOBase_Type,
&PyIncrementalNewlineDecoder_Type,

// PyIOBase_Type subclasses
&PyBufferedIOBase_Type,
Expand Down Expand Up @@ -757,7 +756,7 @@ PyInit__io(void)
}

// Base classes
state->PyIncrementalNewlineDecoder_Type = (PyTypeObject *)Py_NewRef(&PyIncrementalNewlineDecoder_Type);
ADD_TYPE(m, state->PyIncrementalNewlineDecoder_Type, &nldecoder_spec, NULL);

// PyIOBase_Type subclasses
state->PyRawIOBase_Type = (PyTypeObject *)Py_NewRef(&PyRawIOBase_Type);
Expand Down
4 changes: 1 addition & 3 deletions Modules/_io/_iomodule.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ extern PyTypeObject PyRawIOBase_Type;
extern PyTypeObject PyBufferedIOBase_Type;
extern PyTypeObject PyTextIOBase_Type;

/* Concrete classes */
extern PyTypeObject PyIncrementalNewlineDecoder_Type;

/* Type specs */
extern PyType_Spec bufferedrandom_spec;
extern PyType_Spec bufferedreader_spec;
extern PyType_Spec bufferedrwpair_spec;
extern PyType_Spec bufferedwriter_spec;
extern PyType_Spec bytesio_spec;
extern PyType_Spec fileio_spec;
extern PyType_Spec nldecoder_spec;
extern PyType_Spec stringio_spec;
extern PyType_Spec textiowrapper_spec;

Expand Down
82 changes: 40 additions & 42 deletions Modules/_io/textio.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,32 @@ _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self,
return 0;
}

static void
incrementalnewlinedecoder_dealloc(nldecoder_object *self)
static int
incrementalnewlinedecoder_traverse(nldecoder_object *self, visitproc visit,
void *arg)
{
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->decoder);
Py_VISIT(self->errors);
return 0;
}

static int
incrementalnewlinedecoder_clear(nldecoder_object *self)
{
Py_CLEAR(self->decoder);
Py_CLEAR(self->errors);
Py_TYPE(self)->tp_free((PyObject *)self);
return 0;
}

static void
incrementalnewlinedecoder_dealloc(nldecoder_object *self)
{
PyTypeObject *tp = Py_TYPE(self);
_PyObject_GC_UNTRACK(self);
(void)incrementalnewlinedecoder_clear(self);
tp->tp_free((PyObject *)self);
Py_DECREF(tp);
}

static int
Expand Down Expand Up @@ -3176,45 +3196,23 @@ static PyGetSetDef incrementalnewlinedecoder_getset[] = {
{NULL}
};

PyTypeObject PyIncrementalNewlineDecoder_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_io.IncrementalNewlineDecoder", /*tp_name*/
sizeof(nldecoder_object), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)incrementalnewlinedecoder_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
_io_IncrementalNewlineDecoder___init____doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /*tp_weaklistoffset*/
0, /* tp_iter */
0, /* tp_iternext */
incrementalnewlinedecoder_methods, /* tp_methods */
0, /* tp_members */
incrementalnewlinedecoder_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
_io_IncrementalNewlineDecoder___init__, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
static PyType_Slot nldecoder_slots[] = {
{Py_tp_dealloc, incrementalnewlinedecoder_dealloc},
{Py_tp_doc, (void *)_io_IncrementalNewlineDecoder___init____doc__},
{Py_tp_methods, incrementalnewlinedecoder_methods},
{Py_tp_getset, incrementalnewlinedecoder_getset},
{Py_tp_traverse, incrementalnewlinedecoder_traverse},
{Py_tp_clear, incrementalnewlinedecoder_clear},
{Py_tp_init, _io_IncrementalNewlineDecoder___init__},
{0, NULL},
};

PyType_Spec nldecoder_spec = {
.name = "_io.IncrementalNewlineDecoder",
.basicsize = sizeof(nldecoder_object),
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_IMMUTABLETYPE),
.slots = nldecoder_slots,
};


Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ Modules/_io/bufferedio.c - PyBufferedIOBase_Type -
Modules/_io/bytesio.c - _PyBytesIOBuffer_Type -
Modules/_io/iobase.c - PyIOBase_Type -
Modules/_io/iobase.c - PyRawIOBase_Type -
Modules/_io/textio.c - PyIncrementalNewlineDecoder_Type -
Modules/_io/textio.c - PyTextIOBase_Type -
Modules/_io/winconsoleio.c - PyWindowsConsoleIO_Type -
Modules/_testcapi/vectorcall.c - MethodDescriptorBase_Type -
Expand Down

Back | FazBrowse Home | New Git URL