Bug report #14567

Accessing QgsMapRenderer can produce UnicodeDecodeError

Added by Jonas Van Nieuwenberg over 8 years ago. Updated over 8 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Python plugins
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

Description

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.

UnicodeDebug.zip (4.3 KB) Jonas Van Nieuwenberg, 2016-03-24 12:40 PM

Associated revisions

Revision bad0d3e4
Added by Matthias Kuhn over 8 years ago

Properly handle filsystem character encoding when showing warnings

Fix #14567

History

#1 Updated by Alexander Bruy over 8 years ago

  • Status changed from Open to Feedback

Not reproducible with master. I suspect that issue caused by non-ASCII characters in your Windows username.

#2 Updated by Jonas Van Nieuwenberg over 8 years ago

Dear Alexander,

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.

Best regards,
Jonas

#3 Updated by Giovanni Manghi over 8 years ago

  • Status changed from Feedback to Open

#4 Updated by Matthias Kuhn over 8 years ago

  • Status changed from Open to Feedback

Can you verify with the latest master?
There have been some updates which may have resolved the issue.

#5 Updated by Anonymous over 8 years ago

  • Status changed from Feedback to Closed

#6 Updated by Jonas Van Nieuwenberg over 8 years ago

Thank you for the update.

I suppose this implies that the fix will be present in release 2.16, but will it also be patched in the LTR versions (2.8/2.14)?

Best regards,
Jonas

#7 Updated by Jonas Van Nieuwenberg over 8 years ago

  • Status changed from Closed to Reopened
  • Target version set to Version 2.14

Dear,

May I kindly request to have this fix backported to the LTR version (2.14 and/or 2.8)?

Best regards,
Jonas

#8 Updated by Giovanni Manghi over 8 years ago

  • Crashes QGIS or corrupts data changed from Yes to No
  • Status changed from Reopened to Closed
  • Resolution set to fixed/implemented

Also available in: Atom PDF