[GRASS-dev] RE: [GRASS-user] Question with Python-SWIG example
[SEC=UNCLASSIFIED]
Glynn Clements
glynn at gclements.plus.com
Sun May 23 15:09:12 EDT 2010
Martin Landa wrote:
> >> Yes, it's seems to be a ctypes issue.
> >
> > Well, the "manual" ctypes version worked earlier, so it appears to be
> > a problem with the wrappers. The preamble's String type looks
> > unnecessarily complex; there's probably a reason, but I have doubts as
> > to whether the benefits outweight the drawbacks.
> >
> > Can you try r42331? This eliminates most of the preamble, making
> > String and ReturnString aliases for c_char_p. If there's a need for
> > something more complex, I'll deal with that if and when it happens.
>
> Sample script:
>
> #!/usr/bin/env python
> import os, sys
> from grass.lib import grass
> from ctypes import *
>
> grass.G_gisinit(sys.argv[0])
>
> mapset = grass.G_find_raster2("elevation", "")
> print mapset
>
> Result:
>
> Traceback (most recent call last):
> File "/home/martin/smetiste/example7.py", line 8, in <module>
> mapset = grass.G_find_raster2("elevation", "")
> TypeError: __init__ expected at most 1 arguments, got 3
Not only can I not reproduce this, I can't see any mechanism by which
it can occur. Have you done "make clean"? What is the value of
grass.__file__ after importing it?
Given that ctypes_preamble.py defines:
String = c_char_p
ReturnString = c_char_p
it shouldn't be possible for this:
G_find_raster2.argtypes = [c_char_p, c_char_p]
G_find_raster2.restype = c_char_p
to work but this:
G_find_raster2.argtypes = [String, String]
G_find_raster2.restype = ReturnString
to fail.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list