From d834d1c9e62cb20c937b8e42a301d2a63a5d9622 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sat, 18 Apr 2020 14:36:50 +0200 Subject: [PATCH] Backport PR16958: MAINT: Replace uses of tostring with tobytes --- lib/matplotlib/backends/backend_pdf.py | 4 ++-- lib/matplotlib/backends/backend_ps.py | 2 +- lib/matplotlib/backends/backend_wx.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index d3e08d1bcf6d..d1f38990cd10 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -1394,7 +1394,7 @@ def writeGouraudTriangles(self): streamarr['points'] = (flat_points - points_min) * factor streamarr['colors'] = flat_colors[:, :colordim] * 255.0 - self.write(streamarr.tostring()) + self.write(streamarr.tobytes()) self.endStream() self.writeObject(self.gouraudObject, gouraudDict) @@ -1487,7 +1487,7 @@ def _writeImg(self, data, height, width, grayscale, id, smask=None): if png: self._writePng(data) else: - self.currentstream.write(data.tostring()) + self.currentstream.write(data.tobytes()) self.endStream() def writeImages(self): diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index bcc015be516d..d3850cc7cb95 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -694,7 +694,7 @@ def draw_gouraud_triangles(self, gc, points, colors, trans): streamarr['points'] = (flat_points - points_min) * factor streamarr['colors'] = flat_colors[:, :3] * 255.0 - stream = quote_ps_string(streamarr.tostring()) + stream = quote_ps_string(streamarr.tobytes()) self._pswriter.write(f"""\ gsave diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index ac61e1ca31c5..1c7e0c7df7e6 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -288,7 +288,7 @@ def draw_image(self, gc, x, y, im): w = self.width h = self.height rows, cols = im.shape[:2] - bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tostring()) + bitmap = wx.Bitmap.FromBufferRGBA(cols, rows, im.tobytes()) gc = self.get_gc() gc.select() gc.gfx_ctx.DrawBitmap(bitmap, int(l), int(self.height - b),