-
Notifications
You must be signed in to change notification settings - Fork 185
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
Don't try to call _repr_*_
on a class
#817
Conversation
src/PyCall.jl
Outdated
@@ -897,7 +897,10 @@ for (mime, method) in ((MIME"text/html", "_repr_html_"), | |||
throw(MethodError(show, (io, mime, o))) | |||
end | |||
Base.showable(::$mime, o::PyObject) = | |||
!ispynull(o) && hasproperty(o, $method) && let meth = o.$method | |||
!ispynull(o) && | |||
!pyisinstance(o, @pyglobalobj :PyType_Type) && # issue 816 |
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.
Can we use PyCallable_Check
instead?
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.
Issue816._repr_html_
in the OP is callable so I'm not sure if PyCallable_Check
is enough. But maybe PyMethod_Check
would work? I'll check.
I considered a few approaches. I think the best way to do this to port I think this is good to go. (Side notes: 95ee1f1 implements one of the alternative methods by using |
LGTM — |
fix #816
An MWE
The error is due to invoking
Issue816._repr_html_()
. A simple solution seems to just returnfalse
fromshowable("text/html", o)
wheno
is a python type. Although it's probably technically possible to implement_repr_html_
on classes as well, it's very likely virtually nobody uses it.