Trying to run tight_layout with mplcairo broke since #17620 with
ValueError: trying to set draw_gouraud_triangles which is not a method, property, or instance level attribute
because the check isinstance(cls_orig, types.FunctionType) fails for extension methods (such as GraphicsContextRendererCairo.<any method>). Looks like a better check is actually something like isinstance(orig, types.MethodType) and hasattr(type(obj), attr) (the first isinstance check verifies that orig is a bound method and then we just check that the attribute exists on the class and assume that if invoking the descriptor on it gives us a bound method, then we're good) -- at least it works for mplcairo...
Trying to run tight_layout with mplcairo broke since #17620 with
because the check
isinstance(cls_orig, types.FunctionType)fails for extension methods (such asGraphicsContextRendererCairo.<any method>). Looks like a better check is actually something likeisinstance(orig, types.MethodType) and hasattr(type(obj), attr)(the first isinstance check verifies thatorigis a bound method and then we just check that the attribute exists on the class and assume that if invoking the descriptor on it gives us a bound method, then we're good) -- at least it works for mplcairo...