[GRASS-dev] [GRASS GIS] #3392: t.register: encoding error
GRASS GIS
trac at osgeo.org
Fri Aug 11 02:41:42 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 mlennert):
Replying to [comment:2 zarch]:
> Replying to [comment:1 zarch]:
> > Replying to [ticket:3392 mlennert]:
> > > Using the data and examples from [http://ncsu-geoforall-
lab.github.io/grass-temporal-workshop/ 1] in a french (fr_BE at UTF-8)
encoding environment, I get an encoding error using t.register:
> >
> > I was able to reproduce the error, actually the #3394, and with the
attached patch is working on my PC.
> > Can you test it?
>
> I remembered that once Glynn in grass-dev (2016-05-05) said:
>
> ''"Anything using the script module should be using byte strings
throughout (in spite of how awkward Python 3 tries to make this)."''
>
> So I think that instead of returning unicode as I did in the first patch
we should return bytes...
> Please apply the two diff files, and let me know if it is working for
you.
I've applied your patches (BTW: it is always best to make diffs relative
to the source tree root. That way one doesn't have to search for where the
patched files are...).
{{{
t.create output=pluies_nc semantictype=sum title=precipitation_mois
description="Précipitation totale mensuelle NC"Traceback (most recent call
last):
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/scripts/t.create", line 86, in <module>
main()
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/scripts/t.create", line 82, in main
semantic, None, grass.overwrite())
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/open_stds.py", line 174, in open_new_stds
sp.insert(dbif)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/abstract_space_time_dataset.py", line 381,
in insert
statement += AbstractDataset.insert(self, dbif=dbif, execute=False)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/abstract_dataset.py", line 398, in insert
statement += self.metadata.get_insert_statement_mogrified(dbif)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/base.py", line 404, in
get_insert_statement_mogrified
mapset=self.mapset)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/core.py", line 946, in mogrify_sql_statement
return self.connections[mapset].mogrify_sql_statement(content)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/core.py", line 1216, in
mogrify_sql_statement
unicode(args[count]),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2:
ordinal not in range(128)
}}}
However:
{{{
t.create output=pluies_nc semantictype=sum title=precipitation_mois
description="Precipitation totale mensuelle NC"
}}}
Note the accent in the description of the first try, but not the second.
This wasn't a problem before applying your patch.
Then
{{{
t.register -i input=pluies_nc at climate_2000_2012
file=fichier_cartes_tempmean start=2000-01-01 increment="1 months"
Collecte des informations sur la carte ...
100%
Enregistrement des cartes dans la base temporelle ...
Enregistrement des cartes dans le jeu de données temporel ...
Mise à jour du jeu de données temporel ...
ERREUR :ascii,Mettre à jour les métadonnées, l'emprise spatiale et
temporelle de toutes les cartes enregistrées de <,7,8,ordinal not
in range(128)
}}}
And :
{{{
t.unregister file=fichier_cartes_tempmean
Unregister maps
100%
Unregister maps from the temporal database
Traceback (most recent call last):
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/scripts/t.unregister", line 183, in <module>
tgis.profile_function(main)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/core.py", line 85, in profile_function
func()
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/scripts/t.unregister", line 169, in main
sp.update_from_registered_maps(dbif)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/abstract_space_time_dataset.py", line 2295,
in update_from_registered_maps
" all registered maps of <%s>") % (self.get_id()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7:
ordinal not in range(128)
}}}
And:
{{{
t.remove pluies_nc -fNote: registered maps themselves have not been
removed, only the strds
Traceback (most recent call last):
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/scripts/t.remove", line 171, in <module>
tgis.profile_function(main)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/core.py", line 85, in profile_function
func()
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/scripts/t.remove", line 157, in main
statement += sp.delete(dbif=dbif, execute=False)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/abstract_space_time_dataset.py", line 1959,
in delete
self.get_id()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 23:
ordinal not in range(128)
}}}
If this is a fundamental issue in the temporal modules then we should
probably keep the discussion centralized here. I'll close the other bug
reports as duplicates of this one.
t.info (#3394) and t.rast.extract (#3395) now work, but I suspect that the
errors there came from the accent in the description of the strds.
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3392#comment:4>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list