[GRASS-dev] [GRASS GIS] #3782: Python 3: raster/r.in.poly/testsuite/test_rinpoly.py is broken

GRASS GIS trac at osgeo.org
Wed Mar 6 22:53:41 PST 2019


#3782: Python 3: raster/r.in.poly/testsuite/test_rinpoly.py is broken
-------------------------+-------------------------
 Reporter:  pmav99       |      Owner:  grass-dev@…
     Type:  defect       |     Status:  new
 Priority:  normal       |  Milestone:
Component:  Tests        |    Version:  svn-trunk
 Keywords:               |        CPU:  Unspecified
 Platform:  Unspecified  |
-------------------------+-------------------------
 This is the error:
 {{{
 =====================================================================
 ERROR: testLabels (__main__.TestRInPoly)
 Test type of resulting map
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "raster/r.in.poly/testsuite/test_rinpoly.py", line 103, in
 testLabels
     self.tmpFile.write(input1)
   File "/usr/lib/python3.7/tempfile.py", line 481, in func_wrapper
     return func(*args, **kwargs)
 TypeError: a bytes-like object is required, not 'str'
 }}}

 The problems is that NamedTemporaryFiles are opened in binary mode by
 default:
 -
 https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile
 -
 https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile

 This is the git diff for the fix:
 {{{
 diff --git a/raster/r.in.poly/testsuite/test_rinpoly.py
 b/raster/r.in.poly/testsuite/test_rinpoly.py
 index 243dcf9c9..60933bf0c 100644
 --- a/raster/r.in.poly/testsuite/test_rinpoly.py
 +++ b/raster/r.in.poly/testsuite/test_rinpoly.py
 @@ -6,7 +6,7 @@ from grass.script.core import read_command


  input1 = \
 -"""
 +b"""
  A
  634308.630394 223320.356473
  640640.712946 223092.401501
 }}}

 Should work as it is in Python2 too.

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



More information about the grass-dev mailing list