more conservative setattr_cm broke mplcairo · Issue #17646 · matplotlib/matplotlib · GitHub
Skip to content

more conservative setattr_cm broke mplcairo #17646

Description

@anntzer

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...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions