Re: [ctypes-users] Ctypes error
Brought to you by:
theller
From: Thomas H. <th...@py...> - 2003-05-28 17:31:55
|
mna...@ai... writes: > Hi, > > Yes that was the problem. It doesn't work in older versions, and right now > I am using 0.4. But I was a little reluctant to load the new version > because I had everything working "just right" and didn't want to throw off > the balance it has taken me so long to achieve. > > So I decided to try it on a different computer. I set up my configuration > and downloaded the new version. When I ran my script I got this error. > > TypeError: has no _stginfo_ > > The error was in reference to this piece of code. > > class U64(Structure): > _fields_ = [("high", "c_ulong"), > ("low", "c_ulong")] > Correct would be this (without the quotes around c_ulong): class U64(Structure): _fields_ = [("high", c_ulong), ("low", c_ulong)] Of course you have to 'from ctypes import c_ulong' first, but now it's also safe to do 'from ctypes import *'. > >> I was simply following the example given on the website and received the > >> following error: > >> > >> >>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > >> Traceback (most recent call last): > >> File "<pyshell#32>", line 1, in ? > >> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > >> TypeError: wrong type IIRC, in ctypes 0.4 you would have to write ii = TenIntegers(c_int(1), c_int(2), c_int(3)) Thomas |