Message199697
| Author |
ncoghlan |
| Recipients |
arigo, eli.bendersky, eric.snow, ethan.furman, ncoghlan, ronaldoussoren |
| Date |
2013年10月13日.11:53:32 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1381665212.97.0.573533388435.issue16938@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Part of the issue 19030 patch was incorrect and we missed it in the review. Specifically, the else clause in this bit:
try:
get_obj = getattr(cls, name)
except Exception as exc:
pass
else:
homecls = getattr(get_obj, "__class__")
homecls = getattr(get_obj, "__objclass__", homecls)
if homecls not in possible_bases:
# if the resulting object does not live somewhere in the
# mro, drop it and go with the dict_obj version only
homecls = None
get_obj = sentinel
The restriction that the __class__ of the object returned by a descriptor must appear in the MRO doesn't make any sense. The entire else block should be simplified to just:
homecls = getattr(get_obj, "__objclass__", None)
And a "defining class" of None should be documented as a possible result for dynamic attributes that appear in __dir__ but don't set __objclass__ appropriately, and don't correspond to a descriptor. |
|