[issue44655] Confusing error with __slots__

Pablo Galindo Salgado report at bugs.python.org
Fri Jul 16 16:32:10 EDT 2021


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

> it would be nicer if the version with the suggestion were more like the version without the suggestion

Agreed, but that is actually not related with the suggestions. We only append a string at the end of whatever exception it was there. This difference is based on the attribute error for a slot not initialized vs an attribute error for something that is not there. For example, in 3.9:

---

class E:
    __slots__=('blech')

E().blech

Traceback (most recent call last):
  File "/home/pablogsal/github/cpython/lel.py", line 6, in <module>
    E().blech
AttributeError: blech


while

class E:
    __slots__=('blech')

E().bluch

Traceback (most recent call last):
  File "/home/pablogsal/github/cpython/lel.py", line 4, in <module>
    E().bluch
AttributeError: 'E' object has no attribute 'bluch'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44655>
_______________________________________


More information about the Python-bugs-list mailing list