From: SourceForge.net <no...@so...> - 2011-04-11 21:59:49
|
Bugs item #3057804, was opened at 2010-09-01 21:51 Message generated for change (Comment added) made by wsfulton You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3057804&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Amaury Forgeot d'Arc (amauryf) >Assigned to: szager (szager) Summary: [Python] wrapper does not compile with python 3.2 Initial Comment: Since Python 3.2 (still in alpha), the PyCObject API has been removed, the PyCapsule object is proposed as a replacement. Swig wrapper code contains calls to PyCObject_FromVoidPtr, PyCObject_AsVoidPtr and PyCObject_Import, and won't compile anymore. The attached patch fixes the issue and works at least for the wxPython interface, which is quite large and spans several modules sharing the same typesystem. Of course the changes should be guarded by some lines like "#if PY_VERSION_HEX >= 0x03020000" ---------------------------------------------------------------------- >Comment By: William Fulton (wsfulton) Date: 2011-04-11 21:59 Message: Closing as fixed. ---------------------------------------------------------------------- Comment By: szager (szager) Date: 2011-04-11 21:11 Message: I applied the corrected patch to the trunk, revision 12620. ---------------------------------------------------------------------- Comment By: szager (szager) Date: 2011-04-07 05:35 Message: Neither patch looks exactly right. This patch has incorrect python version logic to determine whether to use PyCapsule or PyCObject. Here's what the python header files say about version compatibility: CObjects are marked Pending Deprecation as of Python 2.7. The full schedule for 2.x is as follows: - CObjects are marked Pending Deprecation in Python 2.7. - CObjects will be marked Deprecated in Python 2.8 (if there is one). - CObjects will be removed in Python 2.9 (if there is one). Additionally, for the Python 3.x series: - CObjects were marked Deprecated in Python 3.1. - CObjects will be removed in Python 3.2. >From the other patch, this logic looks correct: #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0)) ... although you might want to add this clause for safety: || (PY_MAJOR_VERSION > 3) In this patch, in the function SWIG_Python_DestroyModule, I think the call to PyCapsule_GetPointer should use this name: (char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer" SWIG_TYPE_TABLE_NAME ... rather than: (char*)"swig_runtime_data" SWIG_RUNTIME_VERSION Note that this patch also blissfully ignores errors: if (swig_module == NULL) { PyErr_Clear(); return; } This patch *does* correctly put an #ifdef around the signature line of SWIG_Python_DestroyModule; the other patch does not. One thing I think both patches have slightly wrong is that the PyCapsule calls in SWIG_Python_TypeQuery should use a NULL name: descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); ... obj = PyCapsule_New(descriptor, NULL, NULL); Since the PyCapsule isn't being added to a module dict, it's not necessary -- or desirable -- to name it. The python docs explicitly allow a NULL name in such a case. With these modifications, I just ran through the test suite using python2.7, and it was clear sailing. ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-10-01 05:22 Message: Thanks for the updated patch. I've just discovered we have another patch for this: https://sourceforge.net/tracker/?func=detail&aid=3047039&group_id=1645&atid=301645 I've not compared the two yet - just noting this before I forget. ---------------------------------------------------------------------- Comment By: Amaury Forgeot d'Arc (amauryf) Date: 2010-09-27 08:11 Message: Here is an updated patch with #ifdef statements: #ifdef SWIG_PYTHON_USE_CAPSULE This symbol is defined for python versions >= 3.2 The PyCapsule object is also available in 2.7, but the symbol is not defined there, to avoid potential compatibility issues. Users can define SWIG_PYTHON_USE_CAPSULE if they want (or to test the feature) ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-27 00:47 Message: Haoyu - you're most familiar with the Python 3 support - can you take a look at this patch? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3057804&group_id=1645 |