Skip to content

Implement delattr for type object #1496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2019
Merged

Conversation

rls1004
Copy link
Contributor

@rls1004 rls1004 commented Oct 9, 2019

Implement delattr for type object

Before

>>>>> class C:
.....   x = 10
..... 
>>>>> del C.x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'type' object has no attribute 'x'
>>>>> C.x
10

After

>>>>> class C:
.....   x = 10
.....
>>>>> del C.x
>>>>> C.x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: C has no attribute 'x'

Fixed: #1404

@rls1004 rls1004 force-pushed the issue1404 branch 2 times, most recently from aa07162 to 85689b4 Compare October 9, 2019 15:18
del a.c
with assert_raises(AttributeError):
_ = a.c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the snippet the from the explanation in the pull request as well? Class attributes probably take another code path as instance attributes.

I mean this snippet:

class C:
    x = 10

...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I added it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An error occurs when deleting an attribute of a class.
2 participants