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

"GRASS GIS" <[email protected]>
Newsgroups gmane.comp.gis.grass.devel
Message-ID <[email protected]>
#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>

_______________________________________________
grass-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.