Skip to content

Commit 97804a5

Browse files
author
Christopher Doris
committed
fix multimedia bug when x is a type
1 parent 1161406 commit 97804a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/compat/multimedia.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ end
2727

2828
# x._repr_mimebundle_()
2929
function pyshow_rule_mimebundle(io::IO, mime::String, x::Py)
30+
pyhasattr(x, "_repr_mimebundle_") || return false
3031
try
31-
ans = x._repr_mimebundle_(include=pylist((mime,)))
32+
ans = pytype(x)._repr_mimebundle_(x, include=pylist([mime]))
3233
if pyisinstance(ans, pybuiltins.tuple)
3334
data = ans[0][mime]
3435
else
@@ -71,8 +72,9 @@ const MIME_TO_REPR_METHOD = Dict(
7172
function pyshow_rule_repr(io::IO, mime::String, x::Py)
7273
method = get(MIME_TO_REPR_METHOD, mime, "")
7374
isempty(method) && return false
75+
pyhasattr(x, method) || return false
7476
try
75-
ans = pygetattr(x, method)()
77+
ans = pygetattr(pytype(x), method)(x)
7678
if pyisinstance(ans, pybuiltins.tuple)
7779
data = ans[0]
7880
else
@@ -103,7 +105,7 @@ const MIME_TO_MATPLOTLIB_FORMAT = Dict(
103105
function pyshow_rule_savefig(io::IO, mime::String, x::Py)
104106
format = get(MIME_TO_MATPLOTLIB_FORMAT, mime, "")
105107
isempty(format) && return false
106-
pyhasattr(x, "savefig") || return false
108+
pyhasattr(x, "savefig") || pyhasattr(x, "figure") || return false
107109
try
108110
plt = pysysmodule.modules["matplotlib.pyplot"]
109111
Figure = plt.Figure

0 commit comments

Comments
 (0)