Skip to content

Commit

Permalink
IPdb: Pass metadata to inline figures
Browse files Browse the repository at this point in the history
This was causing a crash in qtconsole but we discovered the
problem was a bug in MetaKernel.
  • Loading branch information
ccordoba12 committed Sep 22, 2018
1 parent 8644285 commit 4f5c9b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spyder_kernels/ipdb/backend_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ def get_image(figure):
The idea to get png/svg from a figure was taken from
https://stackoverflow.com/a/12145161/438386
"""
# Print figure to a bytes stream
if PY2:
data = io.StringIO()
else:
data = io.BytesIO()

figure.canvas.print_figure(data, bbox_inches='tight')
metadata=_fetch_figure_metadata(figure)

# TODO: Passing metadata is making qtconsole crash
img = Image(data=data.getvalue())
# Get figure metadata
metadata = _fetch_figure_metadata(figure)

img = Image(data=data.getvalue(), metadata=metadata)
return img


Expand Down
4 changes: 4 additions & 0 deletions spyder_kernels/ipdb/tests/test_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ def test_matplotlib_qt(qtconsole, qtbot):

# Assert the previous command returns the object
assert 'PyQt5.QtWidgets.QApplication object' in shell._control.toPlainText()


if __name__ == "__main__":
pytest.main()

0 comments on commit 4f5c9b0

Please sign in to comment.