control: reassign -1 python3-pil On Fri, May 5, 2023 at 3:30 PM Antoine Beaupre <anar...@debian.org> wrote: > > Package: python3-matplotlib > Version: 3.6.3-1+b1 > Severity: important > > I have this tiny script which generates a silly graph of cryptographic > primitives here: > > https://gitlab.com/anarcat/crypto-bench/-/blob/master/benchdiceware.py > > The details are rather irrelevant here, but it eventually does this: > > plt.savefig(args.output, > format=args.output.name[-3:]) > > ... which is basically: > > plt.savefig("foo.png", "png") > > This used to work fine in Python 2. Now that we switched to Python 3, > this explodes with: > > anarcat@angela:crypto-bench$ ./benchpasswords.py -o benchdiceware.png > Traceback (most recent call last): > File "/home/anarcat/src/crypto-bench/./benchpasswords.py", line 102, in > <module> > render_graph(args.output) > File "/home/anarcat/src/crypto-bench/./benchpasswords.py", line 90, in > render_graph > plt.savefig(args.output, > File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 959, in > savefig > res = fig.savefig(*args, **kwargs) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 3285, in > savefig > self.canvas.print_figure(fname, **kwargs) > File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line > 2338, in print_figure > result = print_method( > ^^^^^^^^^^^^^ > File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line > 2204, in <lambda> > print_method = functools.wraps(meth)(lambda *args, **kwargs: meth( > ^^^^^ > File "/usr/lib/python3/dist-packages/matplotlib/_api/deprecation.py", line > 410, in wrapper > return func(*inner_args, **inner_kwargs) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", > line 517, in print_png > self._print_pil(filename_or_obj, "png", pil_kwargs, metadata) > File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", > line 464, in _print_pil > mpl.image.imsave( > File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 1667, in > imsave > image.save(fname, **pil_kwargs) > File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2431, in save > save_handler(self, fp, filename) > File "/usr/lib/python3/dist-packages/PIL/PngImagePlugin.py", line 1307, in > _save > fp.write(_MAGIC) > TypeError: write() argument must be str, not bytes > anarcat@angela:crypto-bench[1]$ > > It looks like matplotlib is calling PIL wrong. Or PIL is wrong itself, > I'm not sure where to lay the blame here...
the crash is in PIL, so reassigning, and it also seems to be potentially limited to the PNG format: i've tried with jpg and eps and they both worked -- Sandro "morph" Tosi My website: http://sandrotosi.me/ Me at Debian: http://wiki.debian.org/SandroTosi Twitter: https://twitter.com/sandrotosi