Bug report #14567
Accessing QgsMapRenderer can produce UnicodeDecodeError
|Affected QGIS version:||2.8.7||Regression?:||No|
|Operating System:||Windows||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||22540|
Steps to reproduce:
0. Have a Windows user account that contains unicode characters (e.g. user "José Fußball").
1. Create a plugin with just the following code:
class UnicodeDebug: def __init__(self, iface): iface.mapCanvas().mapRenderer() def initGui(self): pass def unload(self): pass
2. Launch QGIS Desktop (the issue is at least present in 2.14 and 2.8 but does not seem to occur in early 2.x versions)
3. Encounter the following error message:
Traceback (most recent call last): File "C:/PROGRA~1/QGISWI~1/apps/qgis-ltr/./python\\qgis\\utils.py", line 219, in startPlugin plugins[packageName] = package.classFactory(iface) File "C:/Users/Jos� Fu�ball/.qgis2/python/plugins\\UnicodeDebug\\__init__.py", line 40, in classFactory return UnicodeDebug(iface) File "C:/Users/Jos� Fu�ball/.qgis2/python/plugins\\UnicodeDebug\\UnicodeDebug.py", line 27, in __init__ iface.mapCanvas().mapRenderer() File "C:/PROGRA~1/QGISWI~1/apps/qgis-ltr/./python\\qgis\\utils.py", line 55, in showWarning "warning:%s\ traceback:%s" % ( warnings.formatwarning(message, category, filename, lineno), stk), UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 20: ordinal not in range(128)
Attached is some basic plugin code that can be used to reproduce the issue.
Please let me know if any further information is required.
#2 Updated by Jonas Van Nieuwenberg over 7 years ago
You are completely correct in that observation, as I already mentioned in the very first line of my initial ticket.
Besides the fact that this does not occur for the average user, I still think that it is worth addressing this issue. There are many European countries (e.g. France, Germany) where it is very common to have non-ASCII characters in their username. Leaving this bug unresolved would mean that many Plugins would not be usable for that demographic, as they would all potentially run into this issue.
Moreover, this is not something that Plugin developers can work around themselves. Since the cause of this error is somewhere within the provided QGIS API.