Problem in PyArg_ParseTuple on python 2.5.2 with AIX

John Machin sjmachin at lexicon.net
Mon Jul 27 09:57:26 EDT 2009


On Jul 27, 8:49 pm, abhi <abhigyan_agra... at in.ibm.com> wrote:
> On Jul 27, 2:25 pm, John Machin <sjmac... at lexicon.net> wrote:
>
>
>
> > On Jul 27, 5:11 pm, abhi <abhigyan_agra... at in.ibm.com> wrote:
>
> > > Hi,
> > >     I am facing a problem using PyArg_ParseTuple() in my C-API
> > > extension. Here is a small repro of the function:
>
> > > static PyObject *parsetuple_test(PyObject *self, PyObject *args)
> > > {
> > >         SQLUSMALLINT param_no = 0;
>
> > Sorry, my crystal ball is on the fritz. What is SQLUSMALLINT on
> > Windows/Linux/AIX?
> > What does
> >     printf("%d %d %d\n", sizeof(SQLUSMALLINT), sizeof(int), sizeof
> > (long));
> > give you on each platform?

And the answer was: what?

>     Thanks for the response. If I don't use SQLUSMALLINT and use int
> instead, then also I see the same problem.
> static PyObject *parsetuple_test(PyObject *self, PyObject *args)
>  {
>         int param_no = 0;
> ....
> ....}
>
> This also prints out 0 for AIX and actual value passed in other
> platforms. If I initialize param_no with some other value (e.g. 90),
> it prints out that value.

Please run the following on AIX with Python 2.5:
   import sys
   print sys.byteorder, sys.maxint
   print sys.version
and tell us the output.

Does the C compiler that you are using for the extension correspond
with whatever is mentioned in sys.version about the C compiler used to
compile Python 2.5?

C code: Please add/change as follows:
   int dummy1 = 0xaaaabbbb;
   int param_no = 0xccccdddd;
   int dummy2 = 0xeeeeffff;
...
   printf("%08x %08x %08x\n", dummy1, param_no, dummy2);
   printf("%d %d\n", sizeof(int), sizeof(long));

Try this on AIX (a) with no optimisation (b) whatever O level you have
been using.

Try it with (i) small positive input (i) integer > 65535

Take a copy of your extension and cut out everything that is not part
of executing this function i.e. apart from this function (with the
dummies and printfs) you should have only a few includes, a table
defining just 1 callable function, and the minimal module
initialisation code. Check that this cut down version works on Windows
and Linux and still fails on AIX. Then try it without the first ("O")
arg. If it still fails on AIX, lose the first arg. Publish the minimal
failing code, the instructions to build the .so, and a transcript of
the Python interactive session showing calling the function and the
results.

Cheers,
John



More information about the Python-list mailing list