diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-06-19 19:31:55 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-06-19 19:31:55 +0000 |
| commit | f8073ea1cd935154a50b0b9b8221db1254119100 (patch) | |
| tree | 2c823dd9d7835f4d55cc76c9828fe5b373f3d4d2 /src/runtime/python/pypgf.c | |
| parent | 0ad4c9bf65829b0625fc24d34b79904cab5c6f1b (diff) | |
fíx in the Python binding for compatibility with Python<2.7
Diffstat (limited to 'src/runtime/python/pypgf.c')
| -rw-r--r-- | src/runtime/python/pypgf.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c index 756f7c7cb..dc2d18bfa 100644 --- a/src/runtime/python/pypgf.c +++ b/src/runtime/python/pypgf.c @@ -666,6 +666,15 @@ pypgf_new_python_lexer(PyObject* pylexer, GuPool* pool) return ((PgfLexer*) lexer); } +#if ( (PY_VERSION_HEX < 0x02070000) \ + || ((PY_VERSION_HEX >= 0x03000000) \ + && (PY_VERSION_HEX < 0x03010000)) ) + +#define PyPool_New(pool) \ + PyCObject_FromVoidPtr(pool, gu_pool_free) + +#else + #define PGF_CONTAINER_NAME "pgf.Container" void pypgf_container_descructor(PyObject *capsule) @@ -674,6 +683,12 @@ void pypgf_container_descructor(PyObject *capsule) gu_pool_free(pool); } +#define PyPool_New(pool) \ + PyCapsule_New(pool, PGF_CONTAINER_NAME, \ + pypgf_container_descructor) + +#endif + static IterObject* Concr_parse(ConcrObject* self, PyObject *args, PyObject *keywds) { @@ -712,10 +727,8 @@ Concr_parse(ConcrObject* self, PyObject *args, PyObject *keywds) Py_XINCREF(pyres->grammar); GuPool* out_pool = gu_new_pool(); - - PyObject* py_pool = - PyCapsule_New(out_pool, PGF_CONTAINER_NAME, - pypgf_container_descructor); + + PyObject* py_pool = PyPool_New(out_pool); pyres->container = PyTuple_Pack(2, pyres->grammar, py_pool); Py_DECREF(py_pool); |
