This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients Kamyar Inanloo, brett.cannon, eric.smith
Date 2018-08-14.12:05:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1534248356.84.0.56676864532.issue34387@psf.upfronthosting.co.za>
In-reply-to
Content
I assume this is the behavior you're seeing:

>>> @dataclass
... class C:
...   i: int = 0
...
>>> c = C(10)
>>> c
C(i=10)
>>> del c.i
>>> c
C(i=0)
>>> del c.i
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: i
>>>

If so, that's the expected behavior. You're deleting an instance attribute, so that the class attribute with the same name is seen.

This also happens without dataclasses:

>>> class C:
...   i = 0
...   def __init__(self, i):
...     self.i = i
...
>>> c = C(10)
>>> c.i
10
>>> del c.i
>>> c.i
0
>>> del c.i
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: i
>>>

If you're seeing something different, please re-open this issue.
History
Date User Action Args
2018-08-14 12:05:56eric.smithsetrecipients: + eric.smith, brett.cannon, Kamyar Inanloo
2018-08-14 12:05:56eric.smithsetmessageid: <1534248356.84.0.56676864532.issue34387@psf.upfronthosting.co.za>
2018-08-14 12:05:56eric.smithlinkissue34387 messages
2018-08-14 12:05:56eric.smithcreate