Repository navigation
Closed
Description
Bug report
Bug summary
A large number of tests utilizing ghostscript fail once system ghostscript package is upgraded to 9.52.
Code for reproduction
python -c "import sys, matplotlib as m; sys.exit(m.test(argv=['-m', 'not network', '-x'], verbosity=2))"Actual outcome
==================================================================== FAILURES =====================================================================
___________________________________________________________ test_agg_filter_alpha[pdf] ____________________________________________________________
self = <matplotlib.testing.compare._GSConverter object at 0x7ff3bb1ae160>
orig = PosixPath('/tmp/portage/dev-python/matplotlib-3.3.1/work/matplotlib-3.3.1-python3_9/result_images/test_agg_filter/agg_filter_alpha.pdf')
dest = PosixPath('/tmp/portage/dev-python/matplotlib-3.3.1/work/matplotlib-3.3.1-python3_9/result_images/test_agg_filter/agg_filter_alpha_pdf.png')
def __call__(self, orig, dest):
if not self._proc:
self._proc = subprocess.Popen(
[mpl._get_executable_info("gs").executable,
"-dNOSAFER", "-dNOPAUSE", "-sDEVICE=png16m"],
# As far as I can see, ghostscript never outputs to stderr.
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
try:
> self._read_until(b"\nGS")
build/test-lib/matplotlib/testing/compare.py:130:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <matplotlib.testing.compare._GSConverter object at 0x7ff3bb1ae160>, terminator = b'\nGS'
def _read_until(self, terminator):
"""Read until the prompt is reached."""
buf = bytearray()
while True:
c = self._proc.stdout.read(1)
if not c:
> raise _ConverterError
E matplotlib.testing.compare._ConverterError
build/test-lib/matplotlib/testing/compare.py:115: _ConverterError
The above exception was the direct cause of the following exception:
expected = '/tmp/portage/dev-python/matplotlib-3.3.1/work/matplotlib-3.3.1-python3_9/result_images/test_agg_filter/agg_filter_alpha-expected.pdf'
actual = '/tmp/portage/dev-python/matplotlib-3.3.1/work/matplotlib-3.3.1-python3_9/result_images/test_agg_filter/agg_filter_alpha.pdf', tol = 0
in_decorator = True
def compare_images(expected, actual, tol, in_decorator=False):
"""
Compare two "image" files checking differences within a tolerance.
The two given filenames may point to files which are convertible to
PNG via the `.converter` dictionary. The underlying RMS is calculated
with the `.calculate_rms` function.
Parameters
----------
expected : str
The filename of the expected image.
actual : str
The filename of the actual image.
tol : float
The tolerance (a color value difference, where 255 is the
maximal difference). The test fails if the average pixel
difference is greater than this value.
in_decorator : bool
Determines the output format. If called from image_comparison
decorator, this should be True. (default=False)
Returns
-------
None or dict or str
Return *None* if the images are equal within the given tolerance.
If the images differ, the return value depends on *in_decorator*.
If *in_decorator* is true, a dict with the following entries is
returned:
- *rms*: The RMS of the image difference.
- *expected*: The filename of the expected image.
- *actual*: The filename of the actual image.
- *diff_image*: The filename of the difference image.
- *tol*: The comparison tolerance.
Otherwise, a human-readable multi-line string representation of this
information is returned.
Examples
--------
::
img1 = "./baseline/plot.png"
img2 = "./output/plot.png"
compare_images(img1, img2, 0.001)
"""
actual = os.fspath(actual)
if not os.path.exists(actual):
raise Exception("Output image %s does not exist." % actual)
if os.stat(actual).st_size == 0:
raise Exception("Output image file %s is empty." % actual)
# Convert the image to png
expected = os.fspath(expected)
if not os.path.exists(expected):
raise IOError('Baseline image %r does not exist.' % expected)
extension = expected.split('.')[-1]
if extension != 'png':
> actual = convert(actual, cache=False)
build/test-lib/matplotlib/testing/compare.py:390:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
build/test-lib/matplotlib/testing/compare.py:294: in convert
converter[path.suffix[1:]](path, newpath)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <matplotlib.testing.compare._GSConverter object at 0x7ff3bb1ae160>
orig = PosixPath('/tmp/portage/dev-python/matplotlib-3.3.1/work/matplotlib-3.3.1-python3_9/result_images/test_agg_filter/agg_filter_alpha.pdf')
dest = PosixPath('/tmp/portage/dev-python/matplotlib-3.3.1/work/matplotlib-3.3.1-python3_9/result_images/test_agg_filter/agg_filter_alpha_pdf.png')
def __call__(self, orig, dest):
if not self._proc:
self._proc = subprocess.Popen(
[mpl._get_executable_info("gs").executable,
"-dNOSAFER", "-dNOPAUSE", "-sDEVICE=png16m"],
# As far as I can see, ghostscript never outputs to stderr.
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
try:
self._read_until(b"\nGS")
except _ConverterError as err:
> raise OSError("Failed to start Ghostscript") from err
E OSError: Failed to start Ghostscript
build/test-lib/matplotlib/testing/compare.py:132: OSError
-------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------
CALLED
Note that if I hack it around not to eat stdout, I get the actual error from ghostscript:
------------------------------------------------------------ Captured stdout teardown -------------------------------------------------------------
GPL Ghostscript 9.52 (2020-03-19)
Copyright (C) 2020 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
While reading gs_cidfm.ps:
Error: /undefined in .runlibfileifexists
Operand stack:
(gs_cmap.ps\000gs_setpd.ps\000gs_fapi.ps\000gs_typ32.ps\000gs_frsd.ps\000gs_ll3.ps\000gs_icc.ps\000gs_mex_e.ps\000gs_mro_e.ps\000gs_pdf_e.ps\000gs_wan_e.ps\000pdf_ops.ps\000pdf_rbld.ps\000pdf_base.ps\000pdf_draw.ps\000gs_cff.ps\000gs_mgl_e.ps\000gs_ttf...) (gs_cidfm.ps) 1 --nostringval-- (cidfmap.ja)
Execution stack:
%interp_exit --nostringval-- --nostringval-- %loop_continue --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push --nostringval-- --nostringval-- --nostringval-- --nostringval--
Dictionary stack:
--dict:918/1123(G)-- --dict:0/20(G)-- --dict:71/200(L)-- --dict:918/1123(G)-- --dict:9/14(G)-- --dict:1/1(G)--
Current allocation mode is global
Current file position is 186
Expected outcome
Passing tests.
Matplotlib version
- Operating system: Gentoo Linux
- Matplotlib version: git 6a40954 (also confirmed with 3.3.1 and 3.3.0)
- Matplotlib backend (
print(matplotlib.get_backend())): Qt5Agg - Python version: 3.9.0rc1
- Other libraries: ghostscript-gpl 9.52 (9.50 is fine)
The issue exhibits itself while running tests as part of distribution package build.
Metadata
Metadata
Assignees
Labels
No labels
Activity
QuLogic commentedon Aug 14, 2020
I am runnign with Ghostscript 9.52 on Fedora without any issues, so this seems to be something specific to Gentoo.
github-actions commentedon Aug 16, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
QuLogic commentedon Aug 17, 2023
We've been testing with 9.55 since #26090; I suspect this was a system-specific problem.