[Python-checkins] python/dist/src/Modules pyexpat.c,2.64,2.65
loewis@users.sourceforge.net
loewis@users.sourceforge.net
Sat, 29 Jun 2002 23:41:00 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv24438
Modified Files:
pyexpat.c
Log Message:
Define PyDoc_STRVAR if it is not available (PyXML 1.54).
Remove support for Python 1.5 (PyXML 1.55).
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.64
retrieving revision 2.65
diff -C2 -d -r2.64 -r2.65
*** pyexpat.c 30 Jun 2002 06:03:35 -0000 2.64
--- pyexpat.c 30 Jun 2002 06:40:55 -0000 2.65
***************
*** 1,6 ****
#include "Python.h"
- #if PY_VERSION_HEX < 0x020000B1
- #include <assert.h>
- #endif
#include <ctype.h>
--- 1,3 ----
***************
*** 9,21 ****
#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
#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. */
#define Py_USING_UNICODE
#endif
--- 6,15 ----
#include "expat.h"
! #ifndef PyDoc_STRVAR
! #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#endif
! #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
***************
*** 298,302 ****
#define STRING_CONV_FUNC conv_string_to_utf8
#else
! /* Python 1.6 and later versions */
#define STRING_CONV_FUNC (self->returns_unicode \
? conv_string_to_unicode : conv_string_to_utf8)
--- 292,296 ----
#define STRING_CONV_FUNC conv_string_to_utf8
#else
! /* Python 2.0 and later versions */
#define STRING_CONV_FUNC (self->returns_unicode \
? conv_string_to_unicode : conv_string_to_utf8)
***************
*** 959,967 ****
}
- #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 */
new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
#else
--- 953,958 ----
}
#ifndef Py_TPFLAGS_HAVE_GC
! /* Python versions 2.0 and 2.1 */
new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
#else
***************
*** 969,973 ****
new_parser = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
#endif
- #endif
if (new_parser == NULL)
--- 960,963 ----
***************
*** 1128,1139 ****
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 */
--- 1118,1121 ----
***************
*** 1145,1150 ****
--- 1127,1136 ----
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;
***************
*** 1220,1229 ****
}
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 */
PyObject_Del(self);
#else
--- 1206,1211 ----
}
Py_XDECREF(self->intern);
#ifndef Py_TPFLAGS_HAVE_GC
! /* Code for versions 2.0 and 2.1 */
PyObject_Del(self);
#else
***************
*** 1231,1235 ****
PyObject_GC_Del(self);
#endif
- #endif
}
--- 1213,1216 ----
***************
*** 1563,1599 ****
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
--- 1544,1547 ----