Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e1fdac

Browse files
committed
Remove compatibility code for Python < 2.1, < 2.2 and < 2.4.
1 parent 9988b71 commit 5e1fdac

1 file changed

Lines changed: 0 additions & 42 deletions

File tree

Modules/pyexpat.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,7 @@ trace_frame_exc(PyThreadState *tstate, PyFrameObject *f)
258258
value = Py_None;
259259
Py_INCREF(value);
260260
}
261-
#if PY_VERSION_HEX < 0x02040000
262-
arg = Py_BuildValue("(OOO)", type, value, traceback);
263-
#else
264261
arg = PyTuple_Pack(3, type, value, traceback);
265-
#endif
266262
if (arg == NULL) {
267263
PyErr_Restore(type, value, traceback);
268264
return 0;
@@ -814,11 +810,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
814810

815811
PyTuple_SET_ITEM(arg, 0, bytes);
816812

817-
#if PY_VERSION_HEX < 0x02020000
818-
str = PyObject_CallObject(meth, arg);
819-
#else
820813
str = PyObject_Call(meth, arg, NULL);
821-
#endif
822814
if (str == NULL)
823815
goto finally;
824816

@@ -961,14 +953,7 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
961953
return NULL;
962954
}
963955

964-
#ifndef Py_TPFLAGS_HAVE_GC
965-
/* Python versions 2.0 and 2.1 */
966-
new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
967-
#else
968-
/* Python versions 2.2 and later */
969956
new_parser = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
970-
#endif
971-
972957
if (new_parser == NULL)
973958
return NULL;
974959
new_parser->buffer_size = self->buffer_size;
@@ -983,11 +968,7 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
983968
new_parser->handlers = 0;
984969
new_parser->intern = self->intern;
985970
Py_XINCREF(new_parser->intern);
986-
#ifdef Py_TPFLAGS_HAVE_GC
987971
PyObject_GC_Track(new_parser);
988-
#else
989-
PyObject_GC_Init(new_parser);
990-
#endif
991972

992973
if (self->buffer != NULL) {
993974
new_parser->buffer = malloc(new_parser->buffer_size);
@@ -1158,12 +1139,7 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
11581139
int i;
11591140
xmlparseobject *self;
11601141

1161-
#ifdef Py_TPFLAGS_HAVE_GC
1162-
/* Code for versions 2.2 and later */
11631142
self = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
1164-
#else
1165-
self = PyObject_New(xmlparseobject, &Xmlparsetype);
1166-
#endif
11671143
if (self == NULL)
11681144
return NULL;
11691145

@@ -1183,11 +1159,7 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
11831159
}
11841160
self->intern = intern;
11851161
Py_XINCREF(self->intern);
1186-
#ifdef Py_TPFLAGS_HAVE_GC
11871162
PyObject_GC_Track(self);
1188-
#else
1189-
PyObject_GC_Init(self);
1190-
#endif
11911163
if (self->itself == NULL) {
11921164
PyErr_SetString(PyExc_RuntimeError,
11931165
"XML_ParserCreate failed");
@@ -1216,11 +1188,7 @@ static void
12161188
xmlparse_dealloc(xmlparseobject *self)
12171189
{
12181190
int i;
1219-
#ifdef Py_TPFLAGS_HAVE_GC
12201191
PyObject_GC_UnTrack(self);
1221-
#else
1222-
PyObject_GC_Fini(self);
1223-
#endif
12241192
if (self->itself != NULL)
12251193
XML_ParserFree(self->itself);
12261194
self->itself = NULL;
@@ -1240,13 +1208,7 @@ xmlparse_dealloc(xmlparseobject *self)
12401208
self->buffer = NULL;
12411209
}
12421210
Py_XDECREF(self->intern);
1243-
#ifndef Py_TPFLAGS_HAVE_GC
1244-
/* Code for versions 2.0 and 2.1 */
1245-
PyObject_Del(self);
1246-
#else
1247-
/* Code for versions 2.2 and later. */
12481211
PyObject_GC_Del(self);
1249-
#endif
12501212
}
12511213

12521214
static int
@@ -1571,11 +1533,7 @@ static PyTypeObject Xmlparsetype = {
15711533
(getattrofunc)xmlparse_getattro, /* tp_getattro */
15721534
0, /* tp_setattro */
15731535
0, /* tp_as_buffer */
1574-
#ifdef Py_TPFLAGS_HAVE_GC
15751536
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1576-
#else
1577-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/
1578-
#endif
15791537
Xmlparsetype__doc__, /* tp_doc - Documentation string */
15801538
(traverseproc)xmlparse_traverse, /* tp_traverse */
15811539
(inquiry)xmlparse_clear, /* tp_clear */

0 commit comments

Comments
 (0)