[issue26961] Add operator.get_providing_type

Nick Coghlan report at bugs.python.org
Wed May 4 21:43:34 EDT 2016


New submission from Nick Coghlan:

Prompted by a discussion with Doug Hellmann, I'd like to suggest exposing some of the descriptor MRO walking logic as "operator.get_providing_type".

Specifically, where "getattr(obj, 'attrname')" performs a full attribute lookup and "getattr(type(obj), 'attrname'), performs a type-only attribute lookup, "operator.get_providing_type(obj, 'attrname')" would perform an attribute lookup in the vein of _PyType_Lookup, but report the *type* containing the relevant descriptor, rather than fulling resolving the descriptor protocol.

This would be intended primarily as a debugging aid, for cases where a super() call is reporting an error, but it isn't clear which particular mixin class is failing, and the traceback isn't providing sufficient detail to figure it out (e.g. due to C functions in the call chain).

----------
messages: 264869
nosy: doughellmann, ncoghlan
priority: normal
severity: normal
status: open
title: Add operator.get_providing_type

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26961>
_______________________________________


More information about the Python-bugs-list mailing list