mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-11-01 02:10:27 +03:00
Finish and clean up Python 3 support
- Handle Python 3 types similar to libxml2 - Copy new versions of libxml_xmlXPathDestructNsNode and libxml_xmlXPathObjectPtrConvert from libxml2 - Fix compiler warnings - Fix whitespace - Remove unneeded imports from __future__ - Remove test in extelem.py (StringIO can't be converted to FILE under Python 3) - string.lower() works in both Python 2 and 3 Closes #25.
This commit is contained in:
@@ -15,15 +15,24 @@
|
||||
#include <libxml/xinclude.h>
|
||||
#include <libxml/xpointer.h>
|
||||
|
||||
PyObject* PY_IMPORT_INT(long ival);
|
||||
PyObject* PY_IMPORT_STRING(const char *u);
|
||||
PyObject* PY_IMPORT_CPTRD(void *po, const char *na, void *de);
|
||||
int PY_IMPORT_LONG_CHECK(PyObject *o);
|
||||
int PY_IMPORT_STRING_CHECK(PyObject *o);
|
||||
int PY_IMPORT_CPTR_CHECK(PyObject *o);
|
||||
Py_ssize_t PY_IMPORT_STRING_GET_SIZE(PyObject *o);
|
||||
char* PY_IMPORT_AS_STRING(PyObject *o);
|
||||
long PY_IMPORT_AS_LONG(PyObject *io);
|
||||
/*
|
||||
* for older versions of Python, we don't use PyBytes, but keep PyString
|
||||
* and don't use Capsule but CObjects
|
||||
*/
|
||||
#if PY_VERSION_HEX < 0x02070000
|
||||
#ifndef PyBytes_Check
|
||||
#define PyBytes_Check PyString_Check
|
||||
#define PyBytes_Size PyString_Size
|
||||
#define PyBytes_AsString PyString_AsString
|
||||
#define PyBytes_AS_STRING PyString_AS_STRING
|
||||
#define PyBytes_GET_SIZE PyString_GET_SIZE
|
||||
#endif
|
||||
#ifndef PyCapsule_New
|
||||
#define PyCapsule_New PyCObject_FromVoidPtrAndDesc
|
||||
#define PyCapsule_CheckExact PyCObject_Check
|
||||
#define PyCapsule_GetPointer(o, n) PyCObject_GetDesc((o))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(((PyxmlNode_Object *)(v))->obj))
|
||||
@@ -65,8 +74,16 @@ typedef struct {
|
||||
xmlCatalogPtr obj;
|
||||
} Pycatalog_Object;
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
FILE *libxml_PyFileGet(PyObject *f);
|
||||
void libxml_PyFileRelease(FILE *f);
|
||||
#define PyFile_Get(v) (((v) == Py_None) ? NULL : libxml_PyFileGet(v))
|
||||
#define PyFile_Release(f) libxml_PyFileRelease(f)
|
||||
#else
|
||||
#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
|
||||
#define PyFile_Release(f)
|
||||
#endif
|
||||
|
||||
PyObject * libxml_intWrap(int val);
|
||||
PyObject * libxml_longWrap(long val);
|
||||
|
||||
Reference in New Issue
Block a user