Share

SWIG

Tracker: Bugs

5 Python 2.5 bindings won't compile. - ID: 1552530
Last Update: Comment added ( steveramm )

The Xapian python bindings as generated by swig 1.3.29
fail to compile against the headers for python 2.5:

modern/xapian_wrap.cc: In function 'int
SWIG_Python_ConvertFunctionPtr(PyObject*, void**,
swig_type_info*)':
modern/xapian_wrap.cc:2052: error: invalid conversion
from 'const char*' to 'char*'
modern/xapian_wrap.cc: In function 'void
SWIG_Python_FixMethods(PyMethodDef*, swig_const_info*,
swig_type_info**, swig_type_info**)':
modern/xapian_wrap.cc:22391: error: invalid conversion
from 'const char*' to 'char*'

This appears to be due to python 2.5 changing some char
* members to const char *. The problem can be fixed
using the attached patch, which changes three instances
of "char *" to "const char *" in the generated code.
There may be other such changes needed for other
projects, but this change to swig 1.3.29 allows the
Xapian python bindings to compile.


Richard Boulton ( richardb ) - 2006-09-05 09:59

5

Closed

Fixed

Marcelo Matus

python

None

Public


Comments ( 6 )

Date: 2008-02-04 09:02
Sender: steveramm


Yes - problem solved, thanks!
SWIG Version 1.3.29
C:\Documents and Settings\SRamm.LE>which swig
/usr/bin/swig

- looks like I had one installed with cygwin!
many thanks




Date: 2008-02-01 20:36
Sender: olly


I've no idea about how the dsp works, but I suspect when you run swig
yourself, you are running an older version from before this fix was
committed. When it's run by the dsp, it's running 1.3.33.

What does this report:

swig -version

If that's an older version, you need to install 1.3.33 to replace the
older version, or give an explicit path to the SWIG you want to run.

If there is a SWIG problem here, it might be better to open a fresh bug
for it, as it appears to be essentially unconnected to this one.


Date: 2008-02-01 17:05
Sender: steveramm


OK.
I extracted the swig stuff and then just did:
"C:\swig\swigwin-1.3.33\Examples\python\class>swig -c++ -python example.i"
(like it says in the docs)
to generate wrapper code for the class example.
I fired up developer studio with the .dsp given, and hit build. The errors
came out pretty much as shown in the original bug report, and when I edited
the offending lines, inserting 'const' 3 times, it then built. Output:
"Compiling...
example_wrap.cxx
c:\Python25\include\pyconfig.h(42) : warning C4005:
'_CRT_SECURE_NO_DEPRECATE' : macro redefinition
example_wrap.cxx(124) : see previous definition of
'_CRT_SECURE_NO_DEPRECATE'
example_wrap.cxx(2051) : error C2440: 'initializing' : cannot convert from
'const char *' to 'char *'
Conversion loses qualifiers
example_wrap.cxx(4322) : error C2440: 'initializing' : cannot convert from
'const char *' to 'char *'
Conversion loses qualifiers"
There was one error in "SWIG_Python_ConvertFunctionPtr" and one in
'SWIG_Python_FixMethods(', which hid a third in the same function.
Since then, however, I have *just* discovered that if I hit 'rebuild all'
instead of 'build', I get completely different code that works!
Obviously the project is set up to build it in a different way, but I
haven't looked at the difference yet because I've been chasing my own
bugs.
It would be nice to know the correct options to swig, and to have the docs
fixed!
Many thanks for your quick response.



Date: 2008-02-01 16:33
Sender: olly


The bug Richard reported really was already fixed - I checked his patch
against the tree before closing the bug report. And checking now, we are
still using "const" in those two functions.

There may be other issues with Python 2.5 in some cases, but I don't seem
to have a SWIG tree on a box which has Python 2.5 currently, so it would
save a lot of time if you told us the exact sequence of commands you used,
and the exact error message you got.



Date: 2008-02-01 14:58
Sender: steveramm


I've just downloaded swigwin-1.3.33 and tried to run the 'class' example
for python, and the bug still exists, contrary to the follow-up "Date:
2006-09-05 16:48
Sender: olly
Logged In: YES
user_id=14972

Thanks for the patch, but this has actually already been
fixed in SWIG CVS."



Date: 2006-09-05 15:48
Sender: olly

Logged In: YES
user_id=14972

Thanks for the patch, but this has actually already been
fixed in SWIG CVS.


Attached File ( 1 )

Filename Description Download
swig_patch Patch to swig 1.3.29 Download

Changes ( 4 )

Field Old Value Date By
status_id Open 2006-09-05 15:48 olly
resolution_id None 2006-09-05 15:48 olly
close_date - 2006-09-05 15:48 olly
File Added 192067: swig_patch 2006-09-05 09:59 richardb