[GRASS-dev] [GRASS GIS] #3641: python3/ctypes: ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected LP_struct_Cell_head instance instead of LP_struct_Cell_head

#3641: python3/ctypes: ctypes.ArgumentError: argument 2: <type
'exceptions.TypeError'>: expected LP_struct_Cell_head instance instead of
LP_struct_Cell_head
----------------------------+-------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.8.0
Component: Python | Version: unspecified
Keywords: Python3 ctypes | CPU: Unspecified
Platform: Unspecified |
----------------------------+-------------------------
In a script using i.cutlines which in turn uses GridModule I suddenly get
the following error using trunk:

{{{
Traceback (most recent call last):
   File "/home/mlennert/.grass7/addons/scripts/i.cutlines", line 673, in
<module>
     main()
   File "/home/mlennert/.grass7/addons/scripts/i.cutlines", line 278, in
main
     grd.run()
   File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/grid.py", line 568, in run
     self.patch()
   File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/grid.py", line 609, in patch
     self.start_row, self.start_col, self.out_prefix)
   File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 91, in
rpatch_map
     rpatch_row(rast, rrasts, rbbox)
   File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 41, in
rpatch_row
     sei = get_start_end_index(bboxes)
   File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 25, in
get_start_end_index
     r_start, c_start = coor2pixel((bbox.west, bbox.north), reg)
   File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/utils.py", line 180, in coor2pixel
     return (libraster.Rast_northing_to_row(north, region.byref()),
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected
LP_struct_Cell_head instance instead of LP_struct_Cell_head
}}}

I do not have this error with 7.6.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3641&gt;
GRASS GIS <https://grass.osgeo.org>

Hi Anna,

Any idea where this comes from ? It currently keeps me from using trunk.

Moritz

On 11/09/18 14:59, GRASS GIS wrote:

#3641: python3/ctypes: ctypes.ArgumentError: argument 2: <type
'exceptions.TypeError'>: expected LP_struct_Cell_head instance instead of
LP_struct_Cell_head
----------------------------+-------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.0
Component: Python | Version: unspecified
  Keywords: Python3 ctypes | CPU: Unspecified
  Platform: Unspecified |
----------------------------+-------------------------
  In a script using i.cutlines which in turn uses GridModule I suddenly get
  the following error using trunk:

  {{{
  Traceback (most recent call last):
    File "/home/mlennert/.grass7/addons/scripts/i.cutlines", line 673, in
  <module>
      main()
    File "/home/mlennert/.grass7/addons/scripts/i.cutlines", line 278, in
  main
      grd.run()
    File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
  gnu/etc/python/grass/pygrass/modules/grid/grid.py", line 568, in run
      self.patch()
    File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
  gnu/etc/python/grass/pygrass/modules/grid/grid.py", line 609, in patch
      self.start_row, self.start_col, self.out_prefix)
    File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
  gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 91, in
  rpatch_map
      rpatch_row(rast, rrasts, rbbox)
    File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
  gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 41, in
  rpatch_row
      sei = get_start_end_index(bboxes)
    File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
  gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 25, in
  get_start_end_index
      r_start, c_start = coor2pixel((bbox.west, bbox.north), reg)
    File "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
  gnu/etc/python/grass/pygrass/utils.py", line 180, in coor2pixel
      return (libraster.Rast_northing_to_row(north, region.byref()),
  ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected
  LP_struct_Cell_head instance instead of LP_struct_Cell_head
  }}}

  I do not have this error with 7.6.

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

I can’t reproduce it with the example from manual.

It’s obviously a ctypes problem, that’s one of the issues I haven’t been able to solve, although I thought this comes up only with Python 3, not 2. That’s why I wanted to branch 7.6 first because I knew it might take some time to get these problem fixed in trunk.

On Thu, Sep 13, 2018 at 8:49 AM Moritz Lennert <mlennert@club.worldonline.be> wrote:

Hi Anna,

Any idea where this comes from ? It currently keeps me from using trunk.

Moritz

On 11/09/18 14:59, GRASS GIS wrote:

#3641: python3/ctypes: ctypes.ArgumentError: argument 2: <type
‘exceptions.TypeError’>: expected LP_struct_Cell_head instance instead of
LP_struct_Cell_head
----------------------------±------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.8.0
Component: Python | Version: unspecified
Keywords: Python3 ctypes | CPU: Unspecified
Platform: Unspecified |
----------------------------±------------------------
In a script using i.cutlines which in turn uses GridModule I suddenly get
the following error using trunk:

{{{
Traceback (most recent call last):
File “/home/mlennert/.grass7/addons/scripts/i.cutlines”, line 673, in

main()
File “/home/mlennert/.grass7/addons/scripts/i.cutlines”, line 278, in
main
grd.run()
File “/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/grid.py”, line 568, in run
self.patch()
File “/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/grid.py”, line 609, in patch
self.start_row, self.start_col, self.out_prefix)
File “/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/patch.py”, line 91, in
rpatch_map
rpatch_row(rast, rrasts, rbbox)
File “/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/patch.py”, line 41, in
rpatch_row
sei = get_start_end_index(bboxes)
File “/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/modules/grid/patch.py”, line 25, in
get_start_end_index
r_start, c_start = coor2pixel((bbox.west, bbox.north), reg)
File “/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/pygrass/utils.py”, line 180, in coor2pixel
return (libraster.Rast_northing_to_row(north, region.byref()),
ctypes.ArgumentError: argument 2: <type ‘exceptions.TypeError’>: expected
LP_struct_Cell_head instance instead of LP_struct_Cell_head
}}}

I do not have this error with 7.6.


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

On 13/09/18 16:59, Anna Petrášová wrote:

I can't reproduce it with the example from manual.

Ok, I'll try to see if I can create a reproducible test cast.

Moritz

It's obviously a ctypes problem, that's one of the issues I haven't been able to solve, although I thought this comes up only with Python 3, not 2. That's why I wanted to branch 7.6 first because I knew it might take some time to get these problem fixed in trunk.

On Thu, Sep 13, 2018 at 8:49 AM Moritz Lennert <mlennert@club.worldonline.be <mailto:mlennert@club.worldonline.be>> wrote:

    Hi Anna,

    Any idea where this comes from ? It currently keeps me from using trunk.

    Moritz

    On 11/09/18 14:59, GRASS GIS wrote:
     > #3641: python3/ctypes: ctypes.ArgumentError: argument 2: <type
     > 'exceptions.TypeError'>: expected LP_struct_Cell_head instance
    instead of
     > LP_struct_Cell_head
     > ----------------------------+-------------------------
     > Reporter: mlennert | Owner: grass-dev@…
     > Type: defect | Status: new
     > Priority: normal | Milestone: 7.8.0
     > Component: Python | Version: unspecified
     > Keywords: Python3 ctypes | CPU: Unspecified
     > Platform: Unspecified |
     > ----------------------------+-------------------------
     > In a script using i.cutlines which in turn uses GridModule I
    suddenly get
     > the following error using trunk:
     >
     > {{{
     > Traceback (most recent call last):
     > File "/home/mlennert/.grass7/addons/scripts/i.cutlines", line
    673, in
     > <module>
     > main()
     > File "/home/mlennert/.grass7/addons/scripts/i.cutlines", line
    278, in
     > main
     > grd.run()
     > File
    "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
     > gnu/etc/python/grass/pygrass/modules/grid/grid.py", line 568,
    in run
     > self.patch()
     > File
    "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
     > gnu/etc/python/grass/pygrass/modules/grid/grid.py", line 609,
    in patch
     > self.start_row, self.start_col, self.out_prefix)
     > File
    "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
     > gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 91, in
     > rpatch_map
     > rpatch_row(rast, rrasts, rbbox)
     > File
    "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
     > gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 41, in
     > rpatch_row
     > sei = get_start_end_index(bboxes)
     > File
    "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
     > gnu/etc/python/grass/pygrass/modules/grid/patch.py", line 25, in
     > get_start_end_index
     > r_start, c_start = coor2pixel((bbox.west, bbox.north), reg)
     > File
    "/data/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
     > gnu/etc/python/grass/pygrass/utils.py", line 180, in coor2pixel
     > return (libraster.Rast_northing_to_row(north, region.byref()),
     > ctypes.ArgumentError: argument 2: <type
    'exceptions.TypeError'>: expected
     > LP_struct_Cell_head instance instead of LP_struct_Cell_head
     > }}}
     >
     > I do not have this error with 7.6.
     >
     > _______________________________________________
     > grass-dev mailing list
     > grass-dev@lists.osgeo.org <mailto:grass-dev@lists.osgeo.org>
     > https://lists.osgeo.org/mailman/listinfo/grass-dev
     >

#3641: python3/ctypes: ctypes.ArgumentError: argument 2: <type
'exceptions.TypeError'>: expected LP_struct_Cell_head instance instead of
LP_struct_Cell_head
--------------------------+----------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.0
Component: Python | Version: unspecified
Resolution: | Keywords: Python3 ctypes
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by annakrat):

I don't quite understand what exactly is going on, but there was a missing
wrapper function which got lost during the porting and apparently it is
needed. Try r73339.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3641#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3641: python3/ctypes: ctypes.ArgumentError: argument 2: <type
'exceptions.TypeError'>: expected LP_struct_Cell_head instance instead of
LP_struct_Cell_head
--------------------------+----------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.8.0
Component: Python | Version: unspecified
Resolution: fixed | Keywords: Python3 ctypes
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------
Changes (by mlennert):

* status: new => closed
* resolution: => fixed

Comment:

Replying to [comment:1 annakrat]:
> I don't quite understand what exactly is going on, but there was a
missing wrapper function which got lost during the porting and apparently
it is needed. Try r73339.

This seems to have fixed the issue. Thanks !

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3641#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>