[GRASS-dev] [GRASS GIS] #4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
-----------------------------+---------------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Keywords: ctypes, python3 | CPU: Unspecified
Platform: Unspecified |
-----------------------------+---------------------------------
Alpine edge ships Python 3.8.1. When compiling GRASS 7.8 addons like
i.cutlines (and other) addons, following error occurs:

{{{
Default locale settings are missing. GRASS running with C locale.
Starting GRASS GIS...
Creating new GRASS GIS location <tmploc>...
Cleaning up temporary files...
Executing <g.extension -s extension=i.cutlines> ...
Fetching <i.cutlines> from GRASS GIS Addons repository (be patient)...
Compiling...
Traceback (most recent call last):
   File "/usr/lib/python3.8/ctypes/__init__.py", line 99, in CFUNCTYPE
     return _c_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.c_int'>, (<class
'grass.lib.ctypes_preamble.String'>,), 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
   File "/tmp/grass7-root-73/tmpumv5zbxd/i.cutlines/scripts/i.cutlines",
line 171, in <module>
     from grass.pygrass.modules.grid.grid import GridModule
   File
"/usr/local/grass78/etc/python/grass/pygrass/modules/grid/__init__.py",
line 2, in <module>
     from grass.pygrass.modules.grid.grid import GridModule
   File "/usr/local/grass78/etc/python/grass/pygrass/modules/grid/grid.py",
line 12, in <module>
     from grass.pygrass.gis import Mapset, Location
   File "/usr/local/grass78/etc/python/grass/pygrass/gis/__init__.py", line
13, in <module>
     import grass.lib.gis as libgis
   File "/usr/local/grass78/etc/python/grass/lib/gis.py", line 451, in
<module>
     ('checker', CFUNCTYPE(UNCHECKED(c_int), String)),
   File "/usr/lib/python3.8/ctypes/__init__.py", line 101, in CFUNCTYPE
     class CFunctionType(_CFuncPtr):
TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported.
make: *** [/usr/local/grass78/include/Make/Html.make:14:
i.cutlines.tmp.html] Error 1
ERROR: Compilation failed, sorry. Please check above error messages.
Execution of <g.extension -s extension=i.cutlines> finished.
Cleaning up temporary files...
}}}

We used this docker image:

https://hub.docker.com/r/mundialis/grass-py3-pdal/tags

-> `docker pull mundialis/grass-py3-pdal:stable-alpine`

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

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
----------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Resolution: | Keywords: ctypes, python3
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by Sylvain POULAIN):

Hi,

Don't know if it's related but seems to have same error in archlinux.
Build is fine but launching g.gui wxpython gives errors : All argtypes in
gis.py return error.
Using python 3.8.0 launch grass wxpython succesfully

{{{
$ pacman -Q python-wxpython
python-wxpython 4.0.7-1
$ pacman -Q python
python 3.8.1-3
}}}

{{{
$ grass78
Default locale not found, using UTF-8
Default locale settings are missing. GRASS running with C locale.
Starting GRASS GIS...
Cleaning up temporary files...

           __________ ___ __________ _______________
          / ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
         / / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
        / /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
        \____/_/ |_/_/ |_/____/____/ \____/___//____/

Welcome to GRASS GIS 7.8.2
GRASS GIS homepage: https://grass.osgeo.org
This version running through: Bash Shell (/bin/bash)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
See citation options with: g.version -x
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Launching <wxpython> GUI in the background, please wait...
GRASS 7.8.2 (newLocation):~ > Traceback (most recent call last):
   File "/usr/lib/python3.8/ctypes/__init__.py", line 99, in CFUNCTYPE
     return _c_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.c_int'>, (<class
'grass.lib.ctypes_preamble.String'>,), 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
   File "/opt/grass/gui/wxpython/wxgui.py", line 105, in OnInit
     from lmgr.frame import GMFrame
   File "/opt/grass/gui/wxpython/lmgr/frame.py", line 51, in <module>
     from lmgr.layertree import LayerTree, LMIcons
   File "/opt/grass/gui/wxpython/lmgr/layertree.py", line 38, in <module>
     from mapdisp.frame import MapFrame
   File "/opt/grass/gui/wxpython/mapdisp/frame.py", line 33, in <module>
     from mapdisp.toolbars import MapToolbar, NvizIcons
   File "/opt/grass/gui/wxpython/mapdisp/toolbars.py", line 22, in <module>
     from nviz.main import haveNviz
   File "/opt/grass/gui/wxpython/nviz/main.py", line 24, in <module>
     from nviz import mapwindow
   File "/opt/grass/gui/wxpython/nviz/mapwindow.py", line 42, in <module>
     from nviz.workspace import NvizSettings
   File "/opt/grass/gui/wxpython/nviz/workspace.py", line 23, in <module>
     from nviz import wxnviz
   File "/opt/grass/gui/wxpython/nviz/wxnviz.py", line 51, in <module>
     from grass.lib.gis import *
   File "/opt/grass/etc/python/grass/lib/gis.py", line 552, in <module>
     ('checker', CFUNCTYPE(UNCHECKED(c_int), String)),
   File "/usr/lib/python3.8/ctypes/__init__.py", line 101, in CFUNCTYPE
     class CFunctionType(_CFuncPtr):
TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported.
OnInit returned false, exiting...
}}}

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

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
----------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Resolution: | Keywords: ctypes, python3
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by Sylvain POULAIN):

Well, they will revert changes in 3.8.2 ...
So it will work again with python 3.8.2 :
https://github.com/python/cpython/pull/17960

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

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
----------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Resolution: | Keywords: ctypes, python3
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by carmenTawalika):

Recompiling Python3.8.1 with this patch from pull/17960
(https://github.com/python/cpython/commit/eb9ba2f66df2195a9c6295e73ab3d545a1445f05.patch)
looks promising until now...

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

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
----------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Resolution: | Keywords: ctypes, python3
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by mmetz):

Replying to [comment:3 carmenTawalika]:
> Recompiling Python3.8.1 with this patch from pull/17960
(https://github.com/python/cpython/commit/eb9ba2f66df2195a9c6295e73ab3d545a1445f05.patch)
looks promising until now...

Great, thanks for figuring this out!

Python 3.7.6 and Python 3.8.0 are also affected and need to be patched.

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

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
----------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Resolution: | Keywords: ctypes, python3
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by neteler):

Replying to [comment:4 mmetz]:
> Python 3.7.6 and Python 3.8.0 are also affected and need to be patched.

I have filed a bug report on Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=1794572

Of course, other distros will face the same problem.

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

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
----------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Resolution: | Keywords: ctypes, python3
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by neteler):

Replying to [comment:5 neteler]:
> Replying to [comment:4 mmetz]:
> > Python 3.7.6 and Python 3.8.0 are also affected and need to be
patched.
>
> I have filed a bug report on Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=1794572
> Of course, other distros will face the same problem.

For the record:
  * here the related Alpine Linux patch request:
https://gitlab.alpinelinux.org/alpine/aports/merge_requests/3336

Hint for Fedora users: to downgrade to Python 3.7.4, just run `dnf
downgrade python`.

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

#4015: ctypes: TypeError: item 1 in _argtypes_ passes a union by value, which is
unsupported
----------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.8.3
Component: Python ctypes | Version: git-releasebranch78
Resolution: wontfix | Keywords: ctypes, python3
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------
Changes (by nila):

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

Comment:

Please reopen if needed.

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