summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-06-30 06:40:55 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-06-30 06:40:55 (GMT)
commitb4fcf4d102ac912d6bd38d07a4bb674deaa6e1a9 (patch)
tree2d96209be5d55309dd0a31b4c21da00519597bd7 /Modules
parent6b2cf0e5ea8475436e38418eb206ada06ac52675 (diff)
downloadcpython-b4fcf4d102ac912d6bd38d07a4bb674deaa6e1a9.zip
cpython-b4fcf4d102ac912d6bd38d07a4bb674deaa6e1a9.tar.gz
cpython-b4fcf4d102ac912d6bd38d07a4bb674deaa6e1a9.tar.bz2
Define PyDoc_STRVAR if it is not available (PyXML 1.54).
Remove support for Python 1.5 (PyXML 1.55).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/pyexpat.c74
1 files changed, 11 insertions, 63 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 9cf3935..045b13a 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1,22 +1,16 @@
#include "Python.h"
-#if PY_VERSION_HEX < 0x020000B1
-#include <assert.h>
-#endif
#include <ctype.h>
#include "compile.h"
#include "frameobject.h"
#include "expat.h"
-#ifndef PyGC_HEAD_SIZE
-#define PyGC_HEAD_SIZE 0
-#define PyObject_GC_Init(x)
-#define PyObject_GC_Fini(m)
-#define Py_TPFLAGS_GC 0
+#ifndef PyDoc_STRVAR
+#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#endif
-#if (PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION > 5) || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2)
-/* In Python 1.6, 2.0 and 2.1, disabling Unicode was not possible. */
+#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2)
+/* In Python 2.0 and 2.1, disabling Unicode was not possible. */
#define Py_USING_UNICODE
#endif
@@ -297,7 +291,7 @@ call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args)
#ifndef Py_USING_UNICODE
#define STRING_CONV_FUNC conv_string_to_utf8
#else
-/* Python 1.6 and later versions */
+/* Python 2.0 and later versions */
#define STRING_CONV_FUNC (self->returns_unicode \
? conv_string_to_unicode : conv_string_to_utf8)
#endif
@@ -958,17 +952,13 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
return NULL;
}
-#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
- new_parser = PyObject_NEW(xmlparseobject, &Xmlparsetype);
-#else
#ifndef Py_TPFLAGS_HAVE_GC
- /* Python versions 1.6 to 2.1 */
+ /* Python versions 2.0 and 2.1 */
new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
#else
/* Python versions 2.2 and later */
new_parser = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
#endif
-#endif
if (new_parser == NULL)
return NULL;
@@ -1127,14 +1117,6 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
int i;
xmlparseobject *self;
-#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
- self = PyObject_NEW(xmlparseobject, &Xmlparsetype);
- if (self == NULL)
- return NULL;
-
- self->returns_unicode = 0;
-#else
- /* Code for versions 1.6 and later */
#ifdef Py_TPFLAGS_HAVE_GC
/* Code for versions 2.2 and later */
self = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
@@ -1144,8 +1126,12 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
if (self == NULL)
return NULL;
+#ifdef Py_USING_UNICODE
self->returns_unicode = 1;
+#else
+ self->returns_unicode = 0;
#endif
+
self->buffer = NULL;
self->buffer_size = CHARACTER_DATA_BUFFER_SIZE;
self->buffer_used = 0;
@@ -1219,18 +1205,13 @@ xmlparse_dealloc(xmlparseobject *self)
self->buffer = NULL;
}
Py_XDECREF(self->intern);
-#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
- /* Code for versions before 1.6 */
- free(self);
-#else
#ifndef Py_TPFLAGS_HAVE_GC
- /* Code for versions 1.6 to 2.1 */
+ /* Code for versions 2.0 and 2.1 */
PyObject_Del(self);
#else
/* Code for versions 2.2 and later. */
PyObject_GC_Del(self);
#endif
-#endif
}
static int
@@ -1563,39 +1544,6 @@ static struct PyMethodDef pyexpat_methods[] = {
PyDoc_STRVAR(pyexpat_module_documentation,
"Python wrapper for Expat parser.");
-#if PY_VERSION_HEX < 0x20000F0
-
-/* 1.5 compatibility: PyModule_AddObject */
-static int
-PyModule_AddObject(PyObject *m, char *name, PyObject *o)
-{
- PyObject *dict;
- if (!PyModule_Check(m) || o == NULL)
- return -1;
- dict = PyModule_GetDict(m);
- if (dict == NULL)
- return -1;
- if (PyDict_SetItemString(dict, name, o))
- return -1;
- Py_DECREF(o);
- return 0;
-}
-
-static int
-PyModule_AddIntConstant(PyObject *m, char *name, long value)
-{
- return PyModule_AddObject(m, name, PyInt_FromLong(value));
-}
-
-static int
-PyModule_AddStringConstant(PyObject *m, char *name, char *value)
-{
- return PyModule_AddObject(m, name, PyString_FromString(value));
-}
-
-#endif
-
-
/* Return a Python string that represents the version number without the
* extra cruft added by revision control, even if the right options were
* given to the "cvs export" command to make it not include the extra