[GRASS-dev] [GRASS GIS] #3338: UnicodeDecodeError when registering maps in a STRDS using a translated version of GRASS

#3338: UnicodeDecodeError when registering maps in a STRDS using a translated
version of GRASS
--------------------------------------------+-------------------------
Reporter: lrntct | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.2.2
Component: Temporal | Version: 7.2.0
Keywords: translation UnicodeDecodeError | CPU: x86-64
Platform: Linux |
--------------------------------------------+-------------------------
Using a Spanish locale, the following error appears when trying to
register maps in a STRDS using the python interface:

{{{
Registrando mapas en conjunto de datos espacio temporales...
Actualizando conjunto de datos temporales...
Traceback (most recent call last):
   File "Documentos/tarea_6_5_Roberta.py", line 131, in <module>
     sys.exit(main())
   File "Documentos/tarea_6_5_Roberta.py", line 79, in main
     register_maps_in_strds(TITULO_STRDS, ID_STRDS, DESC_STRDS,
list_nombre_fecha)
   File "Documentos/tarea_6_5_Roberta.py", line 98, in
register_maps_in_strds
     tgis.register.register_map_object_list('raster', map_dts_lst, stds,
delete_empty=True, unit=None)
   File "/usr/lib/grass72/etc/python/grass/temporal/register.py", line 499,
in register_map_object_list
     file=filename, dbif=dbif)
   File "/usr/lib/grass72/etc/python/grass/temporal/register.py", line 341,
in register_maps_in_space_time_dataset
     sp.update_from_registered_maps(dbif)
   File
"/usr/lib/grass72/etc/python/grass/temporal/abstract_space_time_dataset.py",
line 2282, in update_from_registered_maps
     " all registered maps of <%s>") % (self.get_id()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 28:
ordinal not in range(128)
}}}

Changing the system settings to English fix the issue.

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

#3338: UnicodeDecodeError when registering maps in a STRDS using a translated
version of GRASS
-----------------------+--------------------------------------------
  Reporter: lrntct | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: Temporal | Version: 7.2.0
Resolution: | Keywords: translation UnicodeDecodeError
       CPU: x86-64 | Platform: Linux
-----------------------+--------------------------------------------

Comment (by lrntct):

Below is a minimum working example. Try to run it with a Spanish locale,
it will fail. In English, it will run OK.

{{{
import grass.temporal as tgis
import grass.script as gscript
import grass.pygrass.utils as gutils

def create_map_list():
     """Create a list with random raster maps"""
     map_list =
     for i in range(5):
         map_name = 'map_test{}'.format(i)
         map_id = '{}@{}'.format(map_name, gutils.getenv('MAPSET'))
         # create random raster map
         gscript.run_command('r.random.surface', output=map_name,
overwrite=OVR)
         # populate list
         map_list.append((map_id, i))
     return map_list

def register_maps_in_stds(stds_id, map_list):
     """Create a STDS, create one RasterDataset for each map and
     register them in the temporal database
     """
     # create stds
     stds = tgis.open_new_stds(stds_id, 'strds', 'relative',
                               "test", "", "mean", overwrite=OVR)

     # populate MapDataset objects list
     map_dts_lst =
     for map_id, map_time in map_list:
         # create MapDataset
         map_dts = tgis.RasterDataset(map_id)
         # load spatial data from map
         map_dts.load()
         # set time
         map_dts.set_relative_time(map_time, None, 'seconds')
         # populate the list
         map_dts_lst.append(map_dts)
     # Register the maps
     tgis.register.register_map_object_list('raster', map_dts_lst, stds,
                                            delete_empty=True,
unit='seconds')

tgis.init()
register_maps_in_stds('strds_test', create_map_list())
}}}

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

#3338: UnicodeDecodeError when registering maps in a STRDS using a translated
version of GRASS
-----------------------+--------------------------------------------
  Reporter: lrntct | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: Temporal | Version: 7.2.0
Resolution: | Keywords: translation UnicodeDecodeError
       CPU: x86-64 | Platform: Linux
-----------------------+--------------------------------------------
Changes (by neteler):

* Attachment "python_temporal_fix.diff" added.

Remove gettext macros from debug messages

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

#3338: UnicodeDecodeError when registering maps in a STRDS using a translated
version of GRASS
-----------------------+--------------------------------------------
  Reporter: lrntct | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.2
Component: Temporal | Version: 7.2.0
Resolution: | Keywords: translation UnicodeDecodeError
       CPU: x86-64 | Platform: Linux
-----------------------+--------------------------------------------

Comment (by neteler):

Attached a patch to remove undesired gettext macros from debug messages -
a will guess: does it help?

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