11#include "Python.h"
2- #if PY_VERSION_HEX < 0x020000B1
3- #include <assert.h>
4- #endif
52#include <ctype.h>
63
74#include "compile.h"
85#include "frameobject.h"
96#include "expat.h"
107
11- #ifndef PyGC_HEAD_SIZE
12- #define PyGC_HEAD_SIZE 0
13- #define PyObject_GC_Init (x )
14- #define PyObject_GC_Fini (m )
15- #define Py_TPFLAGS_GC 0
8+ #ifndef PyDoc_STRVAR
9+ #define PyDoc_STRVAR (name ,str ) PyDoc_VAR(name) = PyDoc_STR(str)
1610#endif
1711
18- #if (PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION > 5 ) || ( PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2 )
19- /* In Python 1.6, 2.0 and 2.1, disabling Unicode was not possible. */
12+ #if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2 )
13+ /* In Python 2.0 and 2.1, disabling Unicode was not possible. */
2014#define Py_USING_UNICODE
2115#endif
2216
@@ -297,7 +291,7 @@ call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args)
297291#ifndef Py_USING_UNICODE
298292#define STRING_CONV_FUNC conv_string_to_utf8
299293#else
300- /* Python 1.6 and later versions */
294+ /* Python 2.0 and later versions */
301295#define STRING_CONV_FUNC (self->returns_unicode \
302296 ? conv_string_to_unicode : conv_string_to_utf8)
303297#endif
@@ -958,16 +952,12 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
958952 return NULL ;
959953 }
960954
961- #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
962- new_parser = PyObject_NEW (xmlparseobject , & Xmlparsetype );
963- #else
964955#ifndef Py_TPFLAGS_HAVE_GC
965- /* Python versions 1.6 to 2.1 */
956+ /* Python versions 2.0 and 2.1 */
966957 new_parser = PyObject_New (xmlparseobject , & Xmlparsetype );
967958#else
968959 /* Python versions 2.2 and later */
969960 new_parser = PyObject_GC_New (xmlparseobject , & Xmlparsetype );
970- #endif
971961#endif
972962
973963 if (new_parser == NULL )
@@ -1127,14 +1117,6 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
11271117 int i ;
11281118 xmlparseobject * self ;
11291119
1130- #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
1131- self = PyObject_NEW (xmlparseobject , & Xmlparsetype );
1132- if (self == NULL )
1133- return NULL ;
1134-
1135- self -> returns_unicode = 0 ;
1136- #else
1137- /* Code for versions 1.6 and later */
11381120#ifdef Py_TPFLAGS_HAVE_GC
11391121 /* Code for versions 2.2 and later */
11401122 self = PyObject_GC_New (xmlparseobject , & Xmlparsetype );
@@ -1144,8 +1126,12 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
11441126 if (self == NULL )
11451127 return NULL ;
11461128
1129+ #ifdef Py_USING_UNICODE
11471130 self -> returns_unicode = 1 ;
1131+ #else
1132+ self -> returns_unicode = 0 ;
11481133#endif
1134+
11491135 self -> buffer = NULL ;
11501136 self -> buffer_size = CHARACTER_DATA_BUFFER_SIZE ;
11511137 self -> buffer_used = 0 ;
@@ -1219,18 +1205,13 @@ xmlparse_dealloc(xmlparseobject *self)
12191205 self -> buffer = NULL ;
12201206 }
12211207 Py_XDECREF (self -> intern );
1222- #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
1223- /* Code for versions before 1.6 */
1224- free (self );
1225- #else
12261208#ifndef Py_TPFLAGS_HAVE_GC
1227- /* Code for versions 1.6 to 2.1 */
1209+ /* Code for versions 2.0 and 2.1 */
12281210 PyObject_Del (self );
12291211#else
12301212 /* Code for versions 2.2 and later. */
12311213 PyObject_GC_Del (self );
12321214#endif
1233- #endif
12341215}
12351216
12361217static int
@@ -1563,39 +1544,6 @@ static struct PyMethodDef pyexpat_methods[] = {
15631544PyDoc_STRVAR (pyexpat_module_documentation ,
15641545"Python wrapper for Expat parser." );
15651546
1566- #if PY_VERSION_HEX < 0x20000F0
1567-
1568- /* 1.5 compatibility: PyModule_AddObject */
1569- static int
1570- PyModule_AddObject (PyObject * m , char * name , PyObject * o )
1571- {
1572- PyObject * dict ;
1573- if (!PyModule_Check (m ) || o == NULL )
1574- return -1 ;
1575- dict = PyModule_GetDict (m );
1576- if (dict == NULL )
1577- return -1 ;
1578- if (PyDict_SetItemString (dict , name , o ))
1579- return -1 ;
1580- Py_DECREF (o );
1581- return 0 ;
1582- }
1583-
1584- static int
1585- PyModule_AddIntConstant (PyObject * m , char * name , long value )
1586- {
1587- return PyModule_AddObject (m , name , PyInt_FromLong (value ));
1588- }
1589-
1590- static int
1591- PyModule_AddStringConstant (PyObject * m , char * name , char * value )
1592- {
1593- return PyModule_AddObject (m , name , PyString_FromString (value ));
1594- }
1595-
1596- #endif
1597-
1598-
15991547/* Return a Python string that represents the version number without the
16001548 * extra cruft added by revision control, even if the right options were
16011549 * given to the "cvs export" command to make it not include the extra
0 commit comments