On Wed, Jun 15, 2005 at 11:15:59AM +0100, Richard Boulton
wrote:> I'm having a problem compiling the python 2.1 packages for release
0.9.1
> - I get many errors along the lines of:
>
> ../../python/olde/xapian_wrap.cc: In function `PyObject*
> PySwigObject_repr(PySwigObject*)':
> ../../python/olde/xapian_wrap.cc:664: error: `PyString_FromFormat'
> undeclared
> (first use this function)
>
> On further investigation, the copies of xapian_wrap.cc in the olde and
> modern subdirectories of the python binding sources are identical. I
> suspect that something has gone wrong with the source code generation...
No, I think that's correct. It's only xapian.py which is different
between "olde" and "modern". However that's not a
documented feature
of the swig/python -modern switch as far as I could see, so I took the
cautious approach and included both in case a newer swig release starts
producing different .cc and .h files with -modern.
The files are carefully listed in python/Makefile.am such that the
probably identical files go in the tarball next to each other, so when
they're duplicates, gzip should compress them to almost nothing.
> For now, I'm disabling python2.1 from the debian packages so that I can
> get them built.
Sigh. It looks like this was probably broken by moving from SWIG 1.3.23
to SWIG 1.3.24. The latter generates calls to PyString_FromFormat which
was added in Python 2.2. There are some other Python 2.2 assumptions
too.
Applying the attached patch gets it to compile and "make check" then
passes (I forced compilation with -O0 not -O2 due to impatience, but
that shouldn't make a difference).
I'll prod the SWIG developers.
Cheers,
Olly
-------------- next part --------------
--- python/olde/xapian_wrap.cc.orig Tue Jun 7 17:03:51 2005
+++ python/olde/xapian_wrap.cc Wed Jun 15 14:10:30 2005
@@ -39,6 +39,19 @@
#include <Python.h>
+#define PyOS_snprintf snprintf
+static PyObject *
+PyString_FromFormat(const char *fmt, ...) {
+ va_list ap;
+ char buf[2048];
+ int res;
+ va_start(ap, fmt);
+ res = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ return res < 0 ? 0 : PyString_FromString(buf);
+}
+
+
/***********************************************************************
* swigrun.swg
*
@@ -747,7 +760,10 @@
(unaryfunc)PySwigObject_oct, /*nb_oct*/
(unaryfunc)PySwigObject_hex, /*nb_hex*/
#if PY_VERSION_HEX >= 0x02000000
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add ->
nb_inplace_true_divide */
+ 0,0,0,0,0,0,0,0,0,0,0,
+#if PY_VERSION_HEX >= 0x02020000
+ 0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#endif
#endif
};