-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
Provide name suggestions for failed attribute deletions #130425
Comments
Possibly a bug? |
It does seem like something obvious that's missing, but I wasn't 100% sure. Anyway, I was able to implement this by checking for deletion errors in PyObject_SetAttr function (Objects/object.c) and accordingly applying _PyObject_SetAttributeErrorContext. |
@Pranjal095 thanks for raising this! I suspect that the problem is in a bit different place. I proposed my solution. But, looks like we don't have enough tests for this feature. Do you want to contribute? :) |
I checked out your solution, and yes, it is much more suitable than my proposed change. Glad I could help. |
Created #130428 for coordination:-) |
Feature or enhancement
Proposal:
This was initially mentioned as a comment in issue #130399.
Current Output
CPython provides name suggestions when an attribute lookup (obj.attr) fails, but it does not provide similar suggestions when an attribute deletion (del obj.attr) fails. This brings about an inconsistency with regards to the developer experience offered by the language.
Expected Output
Advantages
Note
CPython version - CPython main branch
Operating system - Ubuntu 22.04
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
del obj.attr
#130427The text was updated successfully, but these errors were encountered: