[GRASS-dev] [GRASS GIS] #3392: t.register: encoding error
GRASS GIS
trac at osgeo.org
Sun Aug 20 06:50:57 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:24 annakrat]:
> Yes, I would expect that. As I mentioned before, everywhere in t.*
modules where we use gisenv() we need to run encode, otherwise unicode
gets in the temporal library and results in these errors.
That seems to have been it. Encoding all other gisenv() variables in
core.py solves all error for me. I've committed this in trunk: r71422.
Thanks once again, Anna !
Please others test to see if this causes any regressions for you.
I don't have the feeling that this fix is particularly invasive, but don't
know enough about the python libs nor encoding.
Through too rapid typing I stumbled upon another encoding error by
accident, but this does not seem as urgent to me:
{{{
t.create output=tempmean type=strds temporaltype=absolute title="Average
temperature" description="Monthly temperature average in NC [deg C]"
}}}
Then (note the typo in the strds name):
{{{
t.remove tempmeanµ
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 84, in profile_function
func()
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/scripts/t.remove", line 115, in main
sp = tgis.open_old_stds(name, type, dbif)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/open_stds.py", line 67, in open_old_stds
if not sp.is_in_db(dbif):
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/abstract_dataset.py", line 368, in is_in_db
return self.base.is_in_db(dbif)
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/base.py", line 307, in is_in_db
sql = self.get_is_in_db_statement()
File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/temporal/base.py", line 296, in
get_is_in_db_statement
" WHERE id = \'" + str(self.ident) + "\';\n"
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb5' in
position 8: ordinal not in range(128)
}}}
Not sure how far we have to go in encoding SQL strings as well ?
Also: the checking of strds names does not seem to strict enough:
{{{
t.create output=tempmeanµ type=strds temporaltype=absolute title="Average
temperature" description="Monthly temperature average in NC [deg C]"
ATTENTION: Nom de fichier <tempmeanµ> non autorisé. Caractère <�>
interdit.
}}}
but then:
{{{
t.list
----------------------------------------------
Space time raster datasets with absolute time available in mapset
<climate_2000_2012>:
[...]
tempmeanµ@climate_2000_2012
}}}
So I'm being told through a warning that the character 'µ' is forbidden,
but the strds is still created. I then cannot remove it because of the
above error... Maybe the above warning about the forbidden character
should accompany a fatal error, not a warning ? But this is a different
bug, so I should probably write up a separate report. And IMHO this is not
as urgent as the committed fixes.
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3392#comment:25>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list