[python-sybase] Error in servermsg_cb on amd64

Adam Hooper adamh at densi.com
Tue Aug 30 22:53:20 EST 2005


I had a hell of a time getting python-sybase working on x86-64, and I
ended up with only a workaround, so I thought I'd ask for the proper fix
on the mailing list.

The problem begins in servermsg_cb in ctx.c -- and so an exception is
triggered on the very first command to interact with the server
(ct_connect()).

Coming into servermsg_cb(), cs_msg is a valid CS_SERVERMSG struct, with
msgnumber == 5701 ("Database context switched to 'blah'"). After the
memmove() on line 315 (I'm using python-sybase 0.37),
server_msg->msg.msgnumber == 5701, still. Then comes the Py_BuildValue()
(which I don't understand too well, I'm no Python-C API expert), and
finally call_callback() is called, which calls _servermsg_cb() in
Sybase.py. The first line is:

	mn = msg.msgnumber

However, msg.msgnumber == 8589940293L !

If I ignore that error and proceed, the very next server message (a
database switch, since I pass 4 arguments to Sybase.connect()), comes
back with msg.msgnumber == 4294972997L.

For some reason, Python is using more bits than it needs. 8589940293L ==
2**33 + 5701, and 4294972997L == 2**32 + 5701.

My workaround is to change the line in Sybase.py:_servermsg_cb() to:

	mn = msg.msgnumber % 2**32

Now everything seems to work perfectly! Yay! However, that's obviously
not the proper solution.

Can anybody see what's wrong? Has anybody else gotten python-sybase
working on amd64?

-- 
Adam Hooper <adamh at densi.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.object-craft.com.au/pipermail/python-sybase/attachments/20050830/ca01b498/attachment.pgp


More information about the Python-sybase mailing list