#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 annakrat): The problem mostly comes from calling gisenv function from script.utils which returns unicode. This was done some time ago to make the library Python3 compatible. So we eventually need to move towards unicode, but to have a quick fix for the release, we can keep the temporal library using bytestrings. This is a possible solution: {{{ Index: lib/python/temporal/core.py =================================================================== --- lib/python/temporal/core.py (revision 71395) +++ lib/python/temporal/core.py (working copy) @@ -542,9 +542,9 @@ grassenv = gscript.gisenv() # Set the global variable for faster access - current_mapset = grassenv["MAPSET"] - current_location = grassenv["LOCATION_NAME"] - current_gisdbase = grassenv["GISDBASE"] + current_mapset = gscript.encode(grassenv["MAPSET"]) + current_location = gscript.encode(grassenv["LOCATION_NAME"]) + current_gisdbase = gscript.encode(grassenv["GISDBASE"]) # Check environment variable GRASS_TGIS_RAISE_ON_ERROR if os.getenv("GRASS_TGIS_RAISE_ON_ERROR") == "True" or \ @@ -1107,6 +1107,7 @@ detect_types=self.dbmi.PARSE_DECLTYPES | self.dbmi.PARSE_COLNAMES) self.connection.row_factory = self.dbmi.Row self.connection.isolation_level = None + self.connection.text_factory = str self.cursor = self.connection.cursor() self.cursor.execute("PRAGMA synchronous = OFF") self.cursor.execute("PRAGMA journal_mode = MEMORY") }}} plus all gisenv calls in temporal modules need to be encoded to not let any unicode into the library. I would appreciate if somebody could test it more thoroughly. This would be a temporary solution, we need to move to unicode eventually, but I think that would require more time to fix and more significant changes. Also, this works only for sqlite3 backend, I haven't looked at postgres... -- Ticket URL: <https://trac.osgeo.org/grass/ticket/3392#comment:12> GRASS GIS <https://grass.osgeo.org>
_______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev