Kaydet (Commit) 0c5c6051 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Kör topal idare ediyor.

>>> import iksemel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: initialization of iksemel raised unreported exception
üst e0794cfc
......@@ -105,12 +105,17 @@ AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
[AC_REQUIRE([AM_PATH_PYTHON])
AC_MSG_CHECKING(for headers required to compile python extensions)
dnl deduce PYTHON_INCLUDES
py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
py_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"`
PYTHON_CONFIG=`which $PYTHON`-config
if test -x "$PYTHON_CONFIG"; then
PYTHON_INCLUDES=`$PYTHON_CONFIG --includes 2>/dev/null`
else
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
if test "$py_prefix" != "$py_exec_prefix"; then
PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
fi
fi
AC_SUBST(PYTHON_INCLUDES)
dnl check if the headers exist:
save_CPPFLAGS="$CPPFLAGS"
......@@ -126,8 +131,9 @@ CPPFLAGS="$save_CPPFLAGS"
dnl Check Python for binding
if test "x$with_python" = "xyes"; then
with_python=no
AM_PATH_PYTHON([2.2], , [:])
AM_CHECK_PYTHON_HEADERS(with_python=yes,[AC_MSG_ERROR(could not find Python headers)])
AM_PATH_PYTHON(,, [:])
AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
AM_CHECK_PYTHON_HEADERS(with_python=yes, [AC_MSG_ERROR(could not find Python headers)])
fi
AM_CONDITIONAL([DO_PYTHON], [test "x$with_python" = "xyes"])
......
......@@ -9,4 +9,4 @@ pyexec_LTLIBRARIES = iksemel.la
iksemel_la_LIBADD = $(top_builddir)/src/libiksemel.la
iksemel_la_SOURCES = pyiksemel.c stream.c jid.c document.c reference.c exceptions.c
iksemel_la_CFLAGS = $(CFLAGS) -fno-strict-aliasing
iksemel_la_LDFLAGS = -avoid-version -module -export-symbols-regex initiksemel
iksemel_la_LDFLAGS = -avoid-version -module
......@@ -8,6 +8,11 @@
#include "reference.h"
#include "document.h"
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
#endif
typedef struct {
PyObject_HEAD
PyObject *ref;
......@@ -636,7 +641,7 @@ Document_dealloc(Document *self)
Py_DECREF(self->ref);
self->doc = NULL;
self->ref = NULL;
self->ob_type->tp_free((PyObject *) self);
PyTypeObject* ob_type(PyObject *self);
}
void
......
......@@ -9,7 +9,7 @@
// NOTE: This class uses custom implementation of JID parsing
// instead of the iks_id_new from jabber.c
//
//
typedef struct {
PyObject_HEAD
......@@ -140,7 +140,7 @@ JID_dealloc(JID *self)
if (self->local) { Py_DECREF(self->local); }
if (self->domain) { Py_DECREF(self->domain); }
if (self->resource) { Py_DECREF(self->resource); }
self->ob_type->tp_free((PyObject *) self);
PyTypeObject* ob_type(PyObject *self);
}
void
......
......@@ -10,6 +10,16 @@
#include <Python.h>
#include "iksemel.h"
#if PY_MAJOR_VERSION >= 3
#define PyString_AsString PyBytes_AsString
#define PyString_FromFormat PyUnicode_FromFormat
#endif
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
#endif
void JID_setup(PyObject *module);
......
......@@ -3,6 +3,11 @@
#include "document.h"
#include "node.h"
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
#endif
PyObject *iksemel_module;
/*** Functions ***/
......@@ -98,7 +103,8 @@ static PyMethodDef Node_methods[] = {
};
static PyTypeObject Node_type = {
PyVarObject_HEAD_INIT(NULL,0)
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"iksemel.Node", /* tp_name */
sizeof(Node), /* tp_basicsize */
0, /* tp_itemsize */
......
......@@ -13,12 +13,45 @@
PyObject *iksemel_module;
/*static PyMethodDef methods[] = {
{ "parse", ciks_parse, METH_VARARGS,
"Parse given XML file and generate document tree."},
{ "parseString", ciks_parseString, METH_VARARGS,
"Parse given XML string and generate document tree."},
{ "newDocument", ciks_newDocument, METH_VARARGS,
"Create a new document with given root tag name."},
{ NULL, NULL, 0, NULL }
};*/
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef iksemeldef = {
PyModuleDef_HEAD_INIT,
"iksemel", /* m_name */
"This is a module", /* m_doc */
-1, /* m_size */
NULL, /* m_methods */
NULL, /* m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
};
#endif
#if PY_MAJOR_VERSION >= 3
#define initiksemel PyInit_iksemel
#endif
PyMODINIT_FUNC
initiksemel(void)
{
PyObject *m;
m = Py_InitModule("iksemel", NULL);
#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&iksemeldef);
#else
m = Py_InitModule("iksemel", NULL);
#endif
exceptions_setup(m);
Reference_setup();
......@@ -27,4 +60,5 @@ initiksemel(void)
Stream_setup(m);
iksemel_module = m;
return m;
}
......@@ -6,6 +6,11 @@
#include "reference.h"
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
#endif
typedef struct {
PyObject_HEAD
} Reference;
......@@ -57,7 +62,7 @@ static PyTypeObject Reference_type = {
static void
Reference_dealloc(Reference *self)
{
self->ob_type->tp_free((PyObject *) self);
PyTypeObject* ob_type(PyObject *self);
}
void
......
......@@ -393,7 +393,7 @@ Stream_dealloc(Stream *self)
{
if (self->jid) { Py_DECREF(self->jid); }
iks_parser_delete(self->parser);
self->ob_type->tp_free((PyObject *) self);
PyTypeObject* ob_type(PyObject *self);
}
void
......
......@@ -10,6 +10,15 @@
#include <Python.h>
#include "iksemel.h"
#if PY_MAJOR_VERSION >= 3
#define PyString_AsString PyBytes_AsString
#endif
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
#endif
void Stream_setup(PyObject *module);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment