From da3790fc4e058b029001bf750678fa32360e53f7 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Tue, 20 Sep 2022 15:47:50 +0200 Subject: [PATCH] Fix issue with empty line in ps backend --- lib/matplotlib/backends/backend_ps.py | 5 +++-- lib/matplotlib/tests/test_backend_ps.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index f209e811f18b..67829c216f9a 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -665,8 +665,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): curr_stream[1].append( (item.x, item.ft_object.get_glyph_name(item.glyph_idx)) ) - # append the last entry - stream.append(curr_stream) + # append the last entry if exists + if curr_stream: + stream.append(curr_stream) self.set_color(*gc.get_rgb()) diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index fc2556a47d86..b3e933a89a25 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -256,6 +256,15 @@ def test_linedash(): assert buf.tell() > 0 +def test_empty_line(): + # Smoke-test for gh#23954 + figure = Figure() + figure.text(0.5, 0.5, "\nfoo\n\n") + buf = io.BytesIO() + figure.savefig(buf, format='eps') + figure.savefig(buf, format='ps') + + def test_no_duplicate_definition(): fig = Figure() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy