[New-bugs-announce] [issue46730] Please consider mentioning property without setter when an attribute can't be set

Neil Girdhar report at bugs.python.org
Sat Feb 12 06:15:48 EST 2022


New submission from Neil Girdhar <mistersheik at gmail.com>:

class C:
    @property
    def f(self) -> int:
        return 2

class D(C):
    pass

D().f = 2

Gives:

Traceback (most recent call last):
  File "/home/neil/src/cmm/a.py", line 10, in <module>
    D().f = 2
AttributeError: can't set attribute 'f'

This can be a pain to debug when the property is buried in a base class.  Would it make sense to mention the reason why the attribute can't be set, namely that it's on a property without a setter?

----------
components: Interpreter Core
messages: 413122
nosy: NeilGirdhar
priority: normal
severity: normal
status: open
title: Please consider mentioning property without setter when an attribute can't be set
versions: Python 3.11

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


More information about the New-bugs-announce mailing list