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...

a.

-- System Information:
Debian Release: 12.0
  APT prefers testing-security
  APT policy: (500, 'testing-security'), (500, 'testing-debug'), (500, 
'stable-security'), (500, 'testing'), (500, 'stable'), (1, 'experimental'), (1, 
'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-7-amd64 (SMP w/16 CPU threads; PREEMPT)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages python3-matplotlib depends on:
ii  libc6                               2.36-9
ii  libfreetype6                        2.12.1+dfsg-5
ii  libgcc-s1                           12.2.0-14
ii  libjs-jquery                        3.6.1+dfsg+~3.5.14-1
ii  libjs-jquery-ui                     1.13.2+dfsg-1
ii  libqhull-r8.0                       2020.2-5
ii  libstdc++6                          12.2.0-14
ii  python-matplotlib-data              3.6.3-1
ii  python3                             3.11.2-1+b1
ii  python3-contourpy                   1.0.7-1+b1
ii  python3-cycler                      0.11.0-1
ii  python3-dateutil                    2.8.2-2
ii  python3-fonttools                   4.38.0-1+b1
ii  python3-kiwisolver                  1.4.4-1+b1
ii  python3-numpy [python3-numpy-abi9]  1:1.24.2-1
ii  python3-packaging                   23.0-1
ii  python3-pil                         9.4.0-1.1+b1
ii  python3-pil.imagetk                 9.4.0-1.1+b1
ii  python3-pyparsing                   3.0.9-1
ii  python3-six                         1.16.0-4

Versions of packages python3-matplotlib recommends:
ii  python3-tk  3.10.8-1

Versions of packages python3-matplotlib suggests:
ii  cm-super-minimal     0.3.4-17
pn  dvipng               <none>
ii  ffmpeg               7:5.1.2-3
pn  fonts-staypuft       <none>
ii  ghostscript          10.0.0~dfsg-11
ii  gir1.2-gtk-3.0       3.24.37-2
ii  inkscape             1.2.2-2+b1
ii  ipython3             8.5.0-4
ii  librsvg2-common      2.54.5+dfsg-1
pn  python3-cairocffi    <none>
ii  python3-gi           3.42.2-3+b1
ii  python3-gi-cairo     3.42.2-3+b1
pn  python3-gobject      <none>
ii  python3-pyqt5        5.15.9+dfsg-1
ii  python3-scipy        1.10.1-2
ii  python3-sip          4.19.25+dfsg-5+b1
ii  python3-tornado      6.2.0-3
pn  texlive-extra-utils  <none>
ii  texlive-latex-extra  2022.20230122-3

-- no debconf information

Reply via email to