[GRASS-dev] [GRASS GIS] #2748: ctype.POINTER function overloading prevents automatic byref() conversion
GRASS GIS
trac at osgeo.org
Mon Sep 21 01:59:34 PDT 2015
#2748: ctype.POINTER function overloading prevents automatic byref() conversion
----------------------------+-------------------------
Reporter: artegion | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: Python ctypes | Version: 7.0.1
Resolution: | Keywords:
CPU: Unspecified | Platform: Unspecified
----------------------------+-------------------------
Comment (by artegion):
Replying to [comment:1 glynn]:
> Replying to [ticket:2748 artegion]:
>
> > grass.lib module overwrites ctype.POINTER function in ctypes_preamble
module.
>
> The replacement POINTER function has the following comment:
> {{{
> # Convert None to a real NULL pointer to work around bugs
> # in how ctypes handles None on 64-bit platforms
> }}}
> Have you tested whether this is still an issue (it might have been fixed
since ctypesgen was last updated)?
>
> Having to use byref() explicitly seems less of an issue than not working
on 64-bit systems.
>
> Actually, if an argument is a pointer, the caller should probably be
using byref() explicitly regardless of whether or not ctypes has a
workaround. What's the problem with needing to use byref()?
Not a real problem, just a bit disappointing: python ctypes documentation
describes an interesting feature but our code presents a different
behavior (it is far more pythonic do not care about byreference/byvalue if
ctypes can do the dirty work).
The odd thing is that happens unnoticed: while ctypes raises exceptions
passing wrong argument type in this case only function return code (or
segmentation fault exception) reveals troubles.
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2748#comment:4>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list