diff options
author | Ales Kozumplik <akozumpl@redhat.com> | 2011-11-15 15:49:33 +0100 |
---|---|---|
committer | Ales Kozumplik <akozumpl@redhat.com> | 2011-11-18 10:53:53 +0100 |
commit | c87ad03260fea33da6d64f65709981b06d4e135a (patch) | |
tree | 58ed613c057c9b624970e0772e4d90a6fbf70300 /python/rpmsystem-py.h | |
parent | cd68e2b27e1f98a54c6eae3ae3638b069ce1d9fa (diff) | |
download | rpm-c87ad03260fea33da6d64f65709981b06d4e135a.tar.gz |
python: use the more modern PyCapsule over PyCObject (RhBug:623864).
- rpm.header.new() will still keep accepting PyCObject for now in case a
client library depends on this.
- involves macro trickery to make rpm buildable against python 2.6 still.
Diffstat (limited to 'python/rpmsystem-py.h')
-rw-r--r-- | python/rpmsystem-py.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h index 61ec8ce3f..b73097312 100644 --- a/python/rpmsystem-py.h +++ b/python/rpmsystem-py.h @@ -31,6 +31,16 @@ typedef Py_ssize_t (*lenfunc)(PyObject *); #define PyBytes_AsString PyString_AsString #endif +#if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) < 0x0207 +#define CAPSULE_BUILD(ptr,name) PyCapsule_New(ptr, name, NULL) +#define CAPSULE_CHECK(obj) PyCapsule_CheckExact(obj) +#define CAPSULE_EXTRACT(obj,name) PyCapsule_GetPointer(obj, name) +#else +#define CAPSULE_BUILD(ptr,name) PyCObject_FromVoidPtr(ptr, NULL) +#define CAPSULE_CHECK(obj) PyCObject_Check(obj) +#define CAPSULE_EXTRACT(obj,name) PyCObject_AsVoidPtr(obj) +#endif + /* For Python 3, use the PyLong type throughout in place of PyInt */ #if PY_MAJOR_VERSION >= 3 #define PyInt_Check PyLong_Check |