3
From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py,
4
since they are inappropriate and discouraged in Python documentation
5
(from http://www.python.org/doc/2.5.2/api/includes.html):
7
"All user visible names defined by Python.h (except those defined by the included
8
standard headers) have one of the prefixes "Py" or "_Py". Names beginning with
9
"_Py" are for internal use by the Python implementation and should not be used
10
by extension writers. Structure member names do not have a reserved prefix.
12
Important: user code should never define names that begin with "Py" or "_Py".
13
This confuses the reader, and jeopardizes the portability of the user code to
14
future Python versions, which may define additional names beginning with one
17
This file is a simple script used for change all of these symbols, for user code
21
from shutil import copyfile
26
("PySequence_Base", "SwigPySequence_Base"),
27
("PySequence_Cont", "SwigPySequence_Cont"),
28
("PySwigIterator_T", "SwigPyIterator_T"),
29
("PyPairBoolOutputIterator", "SwigPyPairBoolOutputIterator"),
30
("PySwigIterator", "SwigPyIterator"),
31
("PySwigIterator_T", "SwigPyIterator_T"),
32
("PyMapIterator_T", "SwigPyMapIterator_T"),
33
("PyMapKeyIterator_T", "SwigPyMapKeyIterator_T"),
34
("PyMapValueIterator_T", "SwigPyMapValueITerator_T"),
35
("PyObject_ptr", "SwigPtr_PyObject"),
36
("PyObject_var", "SwigVar_PyObject"),
37
("PyOper", "SwigPyOper"),
38
("PySeq", "SwigPySeq"),
39
("PySequence_ArrowProxy", "SwigPySequence_ArrowProxy"),
40
("PySequence_Cont", "SwigPySequence_Cont"),
41
("PySequence_InputIterator", "SwigPySequence_InputIterator"),
42
("PySequence_Ref", "SwigPySequence_Ref"),
43
("PySwigClientData", "SwigPyClientData"),
44
("PySwigClientData_Del", "SwigPyClientData_Del"),
45
("PySwigClientData_New", "SwigPyClientData_New"),
46
("PySwigIterator", "SwigPyIterator"),
47
("PySwigIteratorClosed_T", "SwigPyIteratorClosed_T"),
48
("PySwigIteratorOpen_T", "SwigPyIteratorOpen_T"),
49
("PySwigIterator_T", "SwigPyIterator_T"),
50
("PySwigObject", "SwigPyObject"),
51
("PySwigObject_Check", "SwigPyObject_Check"),
52
("PySwigObject_GetDesc", "SwigPyObject_GetDesc"),
53
("PySwigObject_New", "SwigPyObject_New"),
54
("PySwigObject_acquire", "SwigPyObject_acquire"),
55
("PySwigObject_append", "SwigPyObject_append"),
56
("PySwigObject_as_number", "SwigPyObject_as_number"),
57
("PySwigObject_compare", "SwigPyObject_compare"),
58
("PySwigObject_dealloc", "SwigPyObject_dealloc"),
59
("PySwigObject_disown", "SwigPyObject_disown"),
60
("PySwigObject_format", "SwigPyObject_format"),
61
("PySwigObject_getattr", "SwigPyObject_getattr"),
62
("PySwigObject_hex", "SwigPyObject_hex"),
63
("PySwigObject_long", "SwigPyObject_long"),
64
("PySwigObject_next", "SwigPyObject_next"),
65
("PySwigObject_oct", "SwigPyObject_oct"),
66
("PySwigObject_own", "SwigPyObject_own"),
67
("PySwigObject_print", "SwigPyObject_print"),
68
("PySwigObject_repr", "SwigPyObject_repr"),
69
("PySwigObject_richcompare", "SwigPyObject_richcompare"),
70
("PySwigObject_str", "SwigPyObject_str"),
71
("PySwigObject_type", "SwigPyObject_type"),
72
("PySwigPacked", "SwigPyPacked"),
73
("PySwigPacked_Check", "SwigPyPacked_Check"),
74
("PySwigPacked_New", "SwigPyPacked_New"),
75
("PySwigPacked_UnpackData", "SwigPyPacked_UnpackData"),
76
("PySwigPacked_compare", "SwigPyPacked_compare"),
77
("PySwigPacked_dealloc", "SwigPyPacked_dealloc"),
78
("PySwigPacked_print", "SwigPyPacked_print"),
79
("PySwigPacked_repr", "SwigPyPacked_repr"),
80
("PySwigPacked_str", "SwigPyPacked_str"),
81
("PySwigPacked_type", "SwigPyPacked_type"),
82
("pyseq", "swigpyseq"),
83
("pyswigobject_type", "swigpyobject_type"),
84
("pyswigpacked_type", "swigpypacked_type"),
87
res = [(re.compile("\\b(%s)\\b"%oldname), newname) for oldname, newname in symbols]
93
for r, newname in res:
94
line, n = r.subn(newname, line)
100
copyfile(fn, fn+".bak")
102
f.write("".join(newf))
110
print "Patched file", fn
112
print "Error occured during patching", fn
115
if __name__=="__main__":
116
if len(sys.argv) > 1:
119
print "Patch your interface file for SWIG's Py* symbol name deprecation."
121
print " %s files..."%sys.argv[0]