diff --git a/src/mplcairo/base.py b/src/mplcairo/base.py index 60d9f45c..b5fe7685 100644 --- a/src/mplcairo/base.py +++ b/src/mplcairo/base.py @@ -286,7 +286,8 @@ def _print_vector(self, renderer_factory, self.figure.draw(renderer) except Exception as exc: draw_raises_done = type(exc).__name__ == "Done" - raise + if not draw_raises_done: # Else, will be re-raised below. + raise finally: # _finish() corresponds finalize() in Matplotlib's PDF and SVG # backends; it is inlined in Matplotlib's PS backend. It must @@ -302,7 +303,7 @@ def _print_vector(self, renderer_factory, if draw_raises_done: renderer = renderer_factory(None, *self.figure.bbox.size, dpi) with _LOCK: - self.figure.draw(renderer) + self.figure.draw(renderer) # Should raise Done(). print_pdf = partialmethod( _print_vector, GraphicsContextRendererCairo._for_pdf_output)