[arch-commits] Commit in swig/trunk (3 files)
Stéphane Gaudreault
stephane at archlinux.org
Wed Feb 23 16:34:20 UTC 2011
Date: Wednesday, February 23, 2011 @ 11:34:20
Author: stephane
Revision: 111014
upgpkg: swig 2.0.2-2
Use PyCapsule API instead of deprecated PyCObject API in python bindings; Fix PySlice* API/ABI issues with the Python 3.2
Added:
swig/trunk/swig-deprecated-pycobject.patch
swig/trunk/swig-pyslice.patch
Modified:
swig/trunk/PKGBUILD
---------------------------------+
PKGBUILD | 19 ++++++-
swig-deprecated-pycobject.patch | 92 ++++++++++++++++++++++++++++++++++++++
swig-pyslice.patch | 45 ++++++++++++++++++
3 files changed, 153 insertions(+), 3 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2011-02-23 16:18:31 UTC (rev 111013)
+++ PKGBUILD 2011-02-23 16:34:20 UTC (rev 111014)
@@ -4,17 +4,30 @@
pkgname=swig
pkgver=2.0.2
-pkgrel=1
+pkgrel=2
pkgdesc="Generate scripting interfaces to C/C++ code"
arch=('i686' 'x86_64')
url="http://www.swig.org/"
license=('custom')
depends=('gcc-libs' 'zlib')
-source=(http://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.gz)
-sha1sums=('1fc5a7b42ae41c51772d7268ba0f987e9514d110')
+source=(http://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.gz
+ swig-deprecated-pycobject.patch
+ swig-pyslice.patch)
+sha1sums=('1fc5a7b42ae41c51772d7268ba0f987e9514d110'
+ 'add71330c5d839d9a27b1ca688e6c5e31f1edb7b'
+ 'a12b59f0415d3a48bad97824861ecfd316a07c3e')
build() {
cd "${srcdir}/${pkgname}-${pkgver}"
+
+ # Use PyCapsule API instead of deprecated PyCObject API in python bindings
+ # See https://bugzilla.redhat.com/show_bug.cgi?id=623854
+ patch -Np1 -i ../swig-deprecated-pycobject.patch
+
+ # Fix PySlice* API/ABI issues with the Python 3.2
+ # See https://bugzilla.redhat.com/show_bug.cgi?id=666429
+ patch -Np1 -i ../swig-pyslice.patch
+
./configure --prefix=/usr
make
}
Added: swig-deprecated-pycobject.patch
===================================================================
--- swig-deprecated-pycobject.patch (rev 0)
+++ swig-deprecated-pycobject.patch 2011-02-23 16:34:20 UTC (rev 111014)
@@ -0,0 +1,92 @@
+diff -up swig-2.0.0/Lib/python/pyrun.swg.rh623854 swig-2.0.0/Lib/python/pyrun.swg
+--- swig-2.0.0/Lib/python/pyrun.swg.rh623854 2010-02-28 00:26:02.000000000 +0100
++++ swig-2.0.0/Lib/python/pyrun.swg 2010-08-17 16:32:16.581604656 +0200
+@@ -45,8 +45,18 @@
+ #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
+ #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
+ #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
+-#define SWIG_fail goto fail
++#define SWIG_fail goto fail
+
++/*
++ * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
++ * CObjects API.
++ */
++#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
++ (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
++#define USE_CAPSULES
++#define TYPE_POINTER_NAME \
++ ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
++#endif
+
+ /* Runtime API implementation */
+
+@@ -1356,8 +1366,12 @@ SWIG_Python_GetModule(void) {
+ #ifdef SWIG_LINK_RUNTIME
+ type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+ #else
++#ifdef USE_CAPSULES
++ type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
++#else
+ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
++#endif
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ type_pointer = (void *)0;
+@@ -1402,9 +1416,14 @@ PyModule_AddObject(PyObject *m, char *na
+ SWIGRUNTIME void
+ SWIG_Python_DestroyModule(void *vptr)
+ {
++ size_t i;
++#ifdef USE_CAPSULES
++ swig_module_info *swig_module =
++ (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
++#else
+ swig_module_info *swig_module = (swig_module_info *) vptr;
++#endif
+ swig_type_info **types = swig_module->types;
+- size_t i;
+ for (i =0; i < swig_module->size; ++i) {
+ swig_type_info *ty = types[i];
+ if (ty->owndata) {
+@@ -1426,9 +1445,18 @@ SWIG_Python_SetModule(swig_module_info *
+ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ swig_empty_runtime_method_table);
+ #endif
++#ifdef USE_CAPSULES
++ PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
++ (PyCapsule_Destructor)SWIG_Python_DestroyModule);
++#else
+ PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
++#endif
+ if (pointer && module) {
++#ifdef USE_CAPSULES
++ PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
++#else
+ PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
++#endif
+ } else {
+ Py_XDECREF(pointer);
+ }
+@@ -1449,12 +1477,20 @@ SWIG_Python_TypeQuery(const char *type)
+ PyObject *obj = PyDict_GetItem(cache, key);
+ swig_type_info *descriptor;
+ if (obj) {
++#ifdef USE_CAPSULES
++ descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
++#else
+ descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
++#endif
+ } else {
+ swig_module_info *swig_module = SWIG_Python_GetModule();
+ descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+ if (descriptor) {
++#ifdef USE_CAPSULES
++ obj = PyCapsule_New(descriptor, type, NULL);
++#else
+ obj = PyCObject_FromVoidPtr(descriptor, NULL);
++#endif
+ PyDict_SetItem(cache, key, obj);
+ Py_DECREF(obj);
+ }
Added: swig-pyslice.patch
===================================================================
--- swig-pyslice.patch (rev 0)
+++ swig-pyslice.patch 2011-02-23 16:34:20 UTC (rev 111014)
@@ -0,0 +1,45 @@
+diff -up swig-2.0.1/Lib/python/pycontainer.swg.rh666429 swig-2.0.1/Lib/python/pycontainer.swg
+--- swig-2.0.1/Lib/python/pycontainer.swg.rh666429 2010-02-28 00:26:02.000000000 +0100
++++ swig-2.0.1/Lib/python/pycontainer.swg 2011-01-03 13:02:29.303515695 +0100
+@@ -631,14 +631,6 @@ namespace swig
+ return x;
+ }
+
+- /* typemap for slice object support */
+- %typemap(in) PySliceObject* {
+- $1 = (PySliceObject *) $input;
+- }
+- %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* {
+- $1 = PySlice_Check($input);
+- }
+-
+ Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) {
+ return swig::getslice(self, i, j);
+ }
+@@ -660,7 +652,7 @@ namespace swig
+ /* Overloaded methods for Python 3 compatibility
+ * (Also useful in Python 2.x)
+ */
+- Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) {
++ Sequence* __getitem__(PyObject *slice) throw (std::out_of_range) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+ SWIG_Error(SWIG_TypeError, "Slice object expected.");
+@@ -670,7 +662,7 @@ namespace swig
+ return swig::getslice(self, i, j);
+ }
+
+- void __setitem__(PySliceObject *slice, const Sequence& v)
++ void __setitem__(PyObject *slice, const Sequence& v)
+ throw (std::out_of_range, std::invalid_argument) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+@@ -681,7 +673,7 @@ namespace swig
+ swig::setslice(self, i, j, v);
+ }
+
+- void __delitem__(PySliceObject *slice)
++ void __delitem__(PyObject *slice)
+ throw (std::out_of_range) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
More information about the arch-commits
mailing list