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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Shriramana Sharma
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>
    UneFenêtre()
  File "./ascii_test_pyqt_2.py", line 8, in __init__
    self.méthode()
  File "./ascii_test_pyqt_2.py", line 11, in méthode
    print(self.nom_de_fenêtre)
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>
    UneAutreFenêtre()
  File "./ascii_test_pyqt_2.py", line 16, in __init__
    self.méthode()
  File "./ascii_test_pyqt_2.py", line 19, in méthode
    print(self.nom_de_fenêtre)
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?

Thanks.

--
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा 𑀰𑁆𑀭𑀻𑀭𑀫𑀡𑀰𑀭𑁆𑀫𑀸

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

ascii_test_pyqt_2.py (738 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Unhelpful error message i.o. "object has no attribute" in case of non-ASCII method names

Shriramana Sharma
By mistake I wrote Kubuntu Xenial 32 bit i.o. 64 bit though I don't
suppose that has any bearing on this…?

--
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा 𑀰𑁆𑀭𑀻𑀭𑀫𑀡𑀰𑀭𑁆𑀫𑀸
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Unhelpful error message i.o. "object has no attribute" in case of non-ASCII method names

Florian Bruhin
In reply to this post by Shriramana Sharma
Hi,

On Mon, Dec 11, 2017 at 08:23:38AM +0530, Shriramana Sharma wrote:
> Hello. I'm using PyQt 5.5.1+dfsg-3ubuntu4 with Py 3.5.1-3 default on
> Kubuntu Xenial 32 bit.

That PyQt version is quite old (October 2015). You might want to upgrade to
something newer. Since Ubuntu Xenial has Python 3.5, you should be able to
install a newer PyQt via pip.

> 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?

Works as expected for me with PyQt 5.9.

Florian

--
https://www.qutebrowser.org  | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Unhelpful error message i.o. "object has no attribute" in case of non-ASCII method names

Shriramana Sharma
Thanks for your checking and feedback. Since PyQt is such a core
component of Kubuntu, I'm wondering how to remove the existing PyQt
packages if I am to manually install PyQt via Pip?

--
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा 𑀰𑁆𑀭𑀻𑀭𑀫𑀡𑀰𑀭𑁆𑀫𑀸
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Unhelpful error message i.o. "object has no attribute" in case of non-ASCII method names

Florian Bruhin
On Mon, Dec 11, 2017 at 04:21:47PM +0530, Shriramana Sharma wrote:
> Thanks for your checking and feedback. Since PyQt is such a core
> component of Kubuntu, I'm wondering how to remove the existing PyQt
> packages if I am to manually install PyQt via Pip?

You don't necessarily need to - you could remove it if you have nothing else
needing it, but you can also just use a virtualenv which I'd recommend anyways:
https://virtualenv.pypa.io/

Florian

--
https://www.qutebrowser.org  | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment