[GRASS-dev] [GRASS GIS] #2581: Fix Python ctypes conversion for stat64 struct on GNU/Hurd

GRASS GIS trac at osgeo.org
Sun Feb 8 07:51:12 PST 2015


#2581: Fix Python ctypes conversion for stat64 struct on GNU/Hurd
---------------------------+------------------------------------------------
 Reporter:  sebastic       |       Owner:  grass-dev@…              
     Type:  defect         |      Status:  new                      
 Priority:  normal         |   Milestone:  7.0.0                    
Component:  Python ctypes  |     Version:  svn-releasebranch70      
 Keywords:                 |    Platform:  Unspecified              
      Cpu:  x86-32         |  
---------------------------+------------------------------------------------
 The Debian package build of GRASS 7.0.0RC1 on the hurd-i386 architecture
 revealed some more issues.

 The attached patch encloses the Python ternary expression in parenthesis
 to fix an issue with the C to Python conversion of the stat & stat64
 structs on GNU/Hurd.

 The structs define the final member conditionally, for the {{{stat64}}}
 structure this is:
 {{{
 #define _SPARE_SIZE     ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
     int st_spare[_SPARE_SIZE];  /* Room for future expansion.  */
 #undef _SPARE_SIZE
 }}}

 This gets converted by {{{ctypesgen}}} to:
 {{{
 ('st_spare', c_int * (sizeof(__fsid_t) == sizeof(c_int)) and 9 or 8),
 }}}

 Which causes a {{{TypeError}}} for every Python script including the
 generated gis.py:
 {{{
 TypeError: second item in _fields_ tuple (index 17) must be a C type
 }}}

 Enclosing the Python expression in parenthesis fixes the error:
 {{{
 ('st_spare', c_int * ((sizeof(__fsid_t) == sizeof(c_int)) and 9 or 8)),
 }}}

 Since [https://pypi.python.org/pypi/ctypesgen ctypesgen] doesn't look
 actively maintained upstream anymore, I'm forwarding this patch for
 inclusion in GRASS only.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/2581>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list