[GRASS-dev] [GRASS GIS] #3392: t.register: encoding error

GRASS GIS trac at osgeo.org
Mon Sep 11 05:44:28 PDT 2017


#3392: t.register: encoding error
--------------------------+---------------------------------
  Reporter:  mlennert     |      Owner:  grass-dev@…
      Type:  defect       |     Status:  new
  Priority:  normal       |  Milestone:  7.2.2
 Component:  Temporal     |    Version:  svn-trunk
Resolution:               |   Keywords:  t.register encoding
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+---------------------------------

Comment (by glynn):

 Replying to [comment:31 annakrat]:

 > Since r65787 script.gisenv() returns unicode, because of Python3 support
 as the commit message says. We need to have a discussion about Python3 and
 what should be the strategy to make the code compatible.

 "because of Python3 support" isn't a reason. "Python 3 support" basically
 means preventing Python 3 from automatically converting everything to
 unicode. Python 3 can still handle byte strings; which is fortunate,
 because I don't expect the C portion of GRASS to be converted to unicode
 in the foreseeable future (if ever).

 The functions in grass.script should **never** return unicode. That module
 reads the contents of files (which are sequences of bytes) and the output
 from processes (again, sequences of bytes). Allowing Python 3 to convert
 byte strings to unicode (and requiring consumers to convert them back to
 byte strings) is error prone. In the few cases where Python 3 refuses to
 return the raw byte strings (e.g. sys.argv, os.environ on Windows),
 grass.script should encode them for compatibility with Python 2. In all
 other cases, the byte strings should be returned as-is.

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



More information about the grass-dev mailing list