[GRASS-dev] [GRASS GIS] #3883: GRASS master does not compile with Python 3 on Mac

GRASS GIS trac at osgeo.org
Thu Feb 27 14:10:09 PST 2020


#3883: GRASS master does not compile with Python 3 on Mac
--------------------------+-------------------------
  Reporter:  cmbarton     |      Owner:  grass-dev@…
      Type:  defect       |     Status:  new
  Priority:  major        |  Milestone:  7.8.3
 Component:  Default      |    Version:  svn-trunk
Resolution:               |   Keywords:
       CPU:  Unspecified  |   Platform:  MacOSX
--------------------------+-------------------------

Comment (by annakrat):

 I would say, the better way to workaround it is to ignore the decoding
 errors for stderr:


 {{{
 --- a/lib/python/ctypes/ctypesgencore/parser/preprocessor.py
 +++ b/lib/python/ctypes/ctypesgencore/parser/preprocessor.py
 @@ -162,15 +162,18 @@ class PreprocessorParser(object):

          self.cparser.handle_status(cmd)

 +        cmd = cmd.encode()
 +
          if sys.platform == 'win32':
 -            cmd = ['sh.exe', '-c', cmd]
 +            cmd = [b'sh.exe', b'-c', cmd]

          pp = subprocess.Popen(cmd,
                                shell=True,
 -                              universal_newlines=True,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
          ppout, pperr = pp.communicate()
 +        ppout = ppout.decode()
 +        pperr = pperr.decode(errors='replace')

          for line in pperr.split("\n"):
              if line:

 }}}

 Alternatively, just pass `errors='replace'` to Popen, but that is not
 available in Python 3.5

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/3883#comment:16>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list