[PyQt] Unhelpful error message i.o. "object has no attribute" in case of non-ASCII method names

Shriramana Sharma samjnaa at gmail.com
Mon Dec 11 02:53:38 GMT 2017

Hello. I'm using PyQt 5.5.1+dfsg-3ubuntu4 with Py 3.5.1-3 default on
Kubuntu Xenial 32 bit. I'm using non-ASCII words for user-defined
variables. Actually it's in an Indic script but for readers'
convenience as minimal example I give the attached code with French.

As expected upon execution it gives the error:

Traceback (most recent call last):
  File "./ascii_test_pyqt_2.py", line 22, in <module>
  File "./ascii_test_pyqt_2.py", line 8, in __init__
  File "./ascii_test_pyqt_2.py", line 11, in méthode
AttributeError: 'UneFenêtre' object has no attribute 'nom_de_fenêtre'

Then I move the self.méthode() call on line 8 to after the next line
and the error is fixed. Then I expect to get a similar error to the
above with the UneAutreFenêtre class which only differs by inheriting
from QWidget and calling its __init__(). But the error I get is:

Traceback (most recent call last):
  File "./ascii_test_pyqt_2.py", line 23, in <module>
  File "./ascii_test_pyqt_2.py", line 16, in __init__
  File "./ascii_test_pyqt_2.py", line 19, in méthode
UnicodeEncodeError: 'ascii' codec can't encode character '\xea' in
position 10: ordinal not in range(128)

The unhelpful message wasn't really helpful to debug the code because
I couldn't understand what ASCII codec was being called for. Is it
possible for a better error message just like the default Python one
to be printed?


Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा 𑀰𑁆𑀭𑀻𑀭𑀫𑀡𑀰𑀭𑁆𑀫𑀸
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ascii_test_pyqt_2.py
Type: text/x-python
Size: 539 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20171211/5500373a/attachment.py>

More information about the PyQt mailing list