-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
always use the local name when building definitions #2564
always use the local name when building definitions #2564
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2564 +/- ##
==========================================
- Coverage 93.10% 93.10% -0.01%
==========================================
Files 93 93
Lines 11065 11064 -1
==========================================
- Hits 10302 10301 -1
Misses 763 763
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For posterity the localname stuff was introduced in 4cdfc82
If I understand it correctly, when doing the initial object_build we try to access getattr(obj, name).name However, this can fail so the code was changed to also have a reference to name itself as a fallback.
Now that I'm re-reviewing this. Could you add a link to the commit in the NB
comment?
Hmm, the commit above answers the question «why have local name» with «because sometimes |
It doesn't exactly fail, it's just that in pypy they do stuff like |
c34ee25
to
1194bcf
Compare
So I found the original bug report: I think the fix as in this PR is still correct: we should always use What do you think @temyurchenko? Edit: Upon reading the code again I think the change to |
Looking at the linked report, the issue was the following: symbols from C modules don't have It's still not clear to me, why we should prefer Why should we prefer |
Sometimes a class accesses a member by a different name than "__name__" of that member: in pypy3 `list.__mul__.__name__ == "__rmul__"`. As a result, in the example above we weren't able to find "list.__mul__", because it was recorded only as "list.__rmul__". it's a part of the campaign to get rid of non-module roots
1194bcf
to
0206036
Compare
Tested this one with pylint tests and the primer, no regressions. |
I've digged and I found an answer for why we have to prefer There are ways to deal with that. I feel like the clearest one is to separate attachment to the locals of a parent from the constructor. Since any object can be attached to the parent by a variety of different names that have no relation to the object itself, it would be clearer to not make it the object's responsibility. So, I am creating a different PR meant to supersede this one. In that PR, I split out adding symbols to the |
A part of getting rid of non-Module roots, see #2536
Sometimes a class accesses a member by a different name than
"name" of that member: in pypy3
list.__mul__.__name__ == "__rmul__"
.As a result, in the example above we weren't able to find
"list.mul", because it was recorded only as "list.rmul".
it's a part of the campaign to get rid of non-module roots