#220 Change of SWIG symbols start with Py

Haoyu Bai

As mentioned by William, there are many SWIG symbols start with Py, which is againsted Python's suggestion (in http://www.python.org/doc/2.5.2/api/includes.html\):

user code should never define names that begin with "Py" or "_Py". This confuses the reader, and jeopardizes the portability of the user code to future Python versions, which may define additional names beginning with one of these prefixes.

This patch changed all those symbols, includes normal C/C++ symbols and SWIG fragments. A list of changes:

PySwig* -> SwigPy*
PyObject_ptr -> SwigPtr_PyObject
PyObject_var -> SwigVar_PyObject
PySequence_Base, PySequence_Cont, PySequence_Ref etc. -> SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref
PyMap* -> SwigPyMap*

Two additional files, Lib/python/pyname_compat.i and Tootls/pyname_patch.py included in this patch. pyname_compat.i provides backward compatibility. pyname_patch.py is a tool used for automatically patch files for the name change.

Please kindly review it, thanks!


  • Haoyu Bai

    Haoyu Bai - 2008-10-11
  • William Fulton

    William Fulton - 2008-11-11

    Thanks for doing this Haoyu. Can you apply to trunk and when we release swig, we'll do a release candidate this time to see if this all goes well. Can you add some more context to pyname_patch.py eg reference the python documentation stating that symbols starting Py should not be used and also put in that this was done in swig-1.3.37. Also add this user level info to CHANGES.current please.

  • Haoyu Bai

    Haoyu Bai - 2008-12-03

    Commited in revision 10961.

  • Haoyu Bai

    Haoyu Bai - 2008-12-03
    • status: open --> closed-accepted

Log in to post a comment.