You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since this commit, I get this error when trying to import data via 'cadastre' module in a PostGIS database :
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 104: ordinal not in range(128)
Traceback (most recent call last):
File "C:/Users/julien.sabatier/.qgis2/python/plugins\cadastre\cadastre_dialogs.py", line 1090, in processImport
qi.importMajic()
File "C:/Users/julien.sabatier/.qgis2/python/plugins\cadastre\cadastre_import.py", line 419, in importMajic
self.executeSqlScript(s, False, item.has_key('constraints'))
File "C:/Users/julien.sabatier/.qgis2/python/plugins\cadastre\cadastre_import.py", line 1064, in executeSqlScript
self.executeSqlQuery(sql, ignoreError)
File "C:/Users/julien.sabatier/.qgis2/python/plugins\cadastre\cadastre_import.py", line 1115, in executeSqlQuery
c = self.connector._execute_and_commit(sql)
File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\db_manager\db_plugins\connector.py", line 95, in _execute_and_commit
self._execute(None, sql)
File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python/plugins\db_manager\db_plugins\connector.py", line 81, in _execute
cursor.execute(str(sql))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 104: ordinal not in range(128)
Version de Python : 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
Version de QGIS : 2.18.10 Las Palmas, 59e0f78
It look like the use of the str function in the connector create this error.
Have you some solution to fix this ? Is it a configuration problem with my environment ?
I tried both on a Deian and Windows platform and each time with the 2.18 version of QGis I have this error.
In fact, the "cadastre" french plugin uses dbmanager tools to run queries. Il would have to adapt the code to be able to manage QGIS before and after this commit. 3liz/QgisCadastrePlugin#106
It seems I can find a workaround by replacing in my code L 461 of cadastre_dialogs.py c = connector._execute(None,unicode(sql))
by c = connector._execute(None,unicode(sql).encode('utf-8'))
@strk could you take a look at https://issues.qgis.org/issues/16833 please?
What was wrong with the previous unicode()? Looks like a mistaken backport from master/Py3? :)
I guess that commit was needed for me to build locally. Travis was
happy so evidently there's a gap in test coverage there :(
Will revert on next occasion (might take a few days before I'm able to
spend time on it). Any chance you can add an automated testcase to
have Travis watch after it ?
10 commit comments
jusabatier commentedon Jun 26, 2017
Since this commit, I get this error when trying to import data via 'cadastre' module in a PostGIS database :
It look like the use of the str function in the connector create this error.
Have you some solution to fix this ? Is it a configuration problem with my environment ?
I tried both on a Deian and Windows platform and each time with the 2.18 version of QGis I have this error.
Gustry commentedon Jun 26, 2017
Hum, yes, users with some accents in the attribute table may have some problems with this commit I think
jusabatier commentedon Jun 26, 2017
To my knowledge, this addon doesn't generate tables with accent in their attributes.
Just add comments on columns with accents : https://github.com/3liz/QgisCadastrePlugin/blob/master/scripts/plugin/commun_create_metier.sql#L1142
Maybe this is the problem.
But I think it have to be solved since it's a regression.
mdouchin commentedon Jul 5, 2017
In fact, the "cadastre" french plugin uses dbmanager tools to run queries. Il would have to adapt the code to be able to manage QGIS before and after this commit.
3liz/QgisCadastrePlugin#106
mdouchin commentedon Jul 5, 2017
It seems I can find a workaround by replacing in my code L 461 of cadastre_dialogs.py
c = connector._execute(None,unicode(sql))
by
c = connector._execute(None,unicode(sql).encode('utf-8'))
@jusabatier Please continue the issue conversation here for the cadastre plugin
3liz/QgisCadastrePlugin#106
borysiasty commentedon Jul 13, 2017
@strk could you take a look at https://issues.qgis.org/issues/16833 please?
What was wrong with the previous unicode()? Looks like a mistaken backport from master/Py3? :)
strk commentedon Jul 17, 2017
strk commentedon Jul 18, 2017
Revert PR is in #4882
strk commentedon Jul 19, 2017
Reverting the commit triggers an infinite loop, see https://travis-ci.org/qgis/QGIS/jobs/255027295
strk commentedon Jul 19, 2017
NOTE: infinite loop only occurs with python3, python2 is fine with the revert. We need a solution working for both.