Skip to content

Commit c13af3c

Browse files
committed
reduce diff for 3.14 and later
1 parent d32a93a commit c13af3c

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

Modules/_lzmamodule.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -809,14 +809,11 @@ Compressor_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
809809
return NULL;
810810
}
811811

812-
assert(type != NULL);
813-
self = PyObject_GC_New(Compressor, type);
812+
assert(type != NULL && type->tp_alloc != NULL);
813+
self = (Compressor *)type->tp_alloc(type, 0);
814814
if (self == NULL) {
815815
return NULL;
816816
}
817-
/* Initialize the remaining fields (untouched by PyObject_GC_New()). */
818-
const size_t offset = sizeof(struct { PyObject_HEAD });
819-
memset((char *)self + offset, 0, sizeof(*self) - offset);
820817

821818
self->alloc.opaque = NULL;
822819
self->alloc.alloc = PyLzma_Malloc;
@@ -830,6 +827,7 @@ Compressor_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
830827
return NULL;
831828
}
832829

830+
self->flushed = 0;
833831
switch (format) {
834832
case FORMAT_XZ:
835833
if (check == -1) {
@@ -1245,19 +1243,16 @@ _lzma_LZMADecompressor_impl(PyTypeObject *type, int format,
12451243
return NULL;
12461244
}
12471245

1248-
assert(type != NULL);
1249-
self = PyObject_GC_New(Decompressor, type);
1246+
assert(type != NULL && type->tp_alloc != NULL);
1247+
self = (Decompressor *)type->tp_alloc(type, 0);
12501248
if (self == NULL) {
12511249
return NULL;
12521250
}
1253-
/* Initialize the remaining fields (untouched by PyObject_GC_New()). */
1254-
const size_t offset = sizeof(struct { PyObject_HEAD });
1255-
memset((char *)self + offset, 0, sizeof(*self) - offset);
1256-
12571251
self->alloc.opaque = NULL;
12581252
self->alloc.alloc = PyLzma_Malloc;
12591253
self->alloc.free = PyLzma_Free;
12601254
self->lzs.allocator = &self->alloc;
1255+
self->lzs.next_in = NULL;
12611256

12621257
self->lock = PyThread_allocate_lock();
12631258
if (self->lock == NULL) {
@@ -1268,7 +1263,9 @@ _lzma_LZMADecompressor_impl(PyTypeObject *type, int format,
12681263

12691264
self->check = LZMA_CHECK_UNKNOWN;
12701265
self->needs_input = 1;
1271-
self->unused_data = PyBytes_FromStringAndSize(NULL, 0);
1266+
self->input_buffer = NULL;
1267+
self->input_buffer_size = 0;
1268+
Py_XSETREF(self->unused_data, PyBytes_FromStringAndSize(NULL, 0));
12721269
if (self->unused_data == NULL) {
12731270
goto error;
12741271
}

0 commit comments

Comments
 (0)