Skip to content

Commit 3d76f2d

Browse files
authored
Merge pull request #27793 from QuLogic/backport-crash-fixes
Backport crash fixes to v3.7.x
2 parents 03947d0 + e97c7f3 commit 3d76f2d

File tree

6 files changed

+53
-35
lines changed

6 files changed

+53
-35
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
https://github.com/qhull/qhull/raw/2020.2/COPYING.txt
7171
7272
- name: Build wheels for CPython 3.12
73-
uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
73+
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
7474
env:
7575
CIBW_BUILD: "cp312-*"
7676
CIBW_SKIP: "*-musllinux* *i686* *win32*"
@@ -94,7 +94,7 @@ jobs:
9494
pip install --pre "numpy>=1.25"
9595
9696
- name: Build wheels for CPython 3.11
97-
uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
97+
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
9898
env:
9999
CIBW_BUILD: "cp311-*"
100100
CIBW_SKIP: "*-musllinux*"
@@ -107,7 +107,7 @@ jobs:
107107
CIBW_ARCHS: ${{ matrix.cibw_archs }}
108108

109109
- name: Build wheels for CPython 3.10
110-
uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
110+
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
111111
env:
112112
CIBW_BUILD: "cp310-*"
113113
CIBW_SKIP: "*-musllinux*"
@@ -120,7 +120,7 @@ jobs:
120120
CIBW_ARCHS: ${{ matrix.cibw_archs }}
121121

122122
- name: Build wheels for CPython 3.9
123-
uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
123+
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
124124
env:
125125
CIBW_BUILD: "cp39-*"
126126
CIBW_SKIP: "*-musllinux*"
@@ -133,7 +133,7 @@ jobs:
133133
CIBW_ARCHS: ${{ matrix.cibw_archs }}
134134

135135
- name: Build wheels for CPython 3.8
136-
uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
136+
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
137137
env:
138138
CIBW_BUILD: "cp38-*"
139139
CIBW_SKIP: "*-musllinux*"
@@ -146,7 +146,7 @@ jobs:
146146
CIBW_ARCHS: ${{ matrix.cibw_archs }}
147147

148148
- name: Build wheels for PyPy 3.8
149-
uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
149+
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
150150
env:
151151
CIBW_BUILD: "pp38-*"
152152
CIBW_SKIP: "*-musllinux*"
@@ -157,7 +157,7 @@ jobs:
157157
if: matrix.cibw_archs != 'aarch64'
158158

159159
- name: Build wheels for PyPy 3.9
160-
uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
160+
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
161161
env:
162162
CIBW_BUILD: "pp39-*"
163163
CIBW_SKIP: "*-musllinux*"

lib/matplotlib/backends/backend_pgf.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -286,24 +286,14 @@ def __init__(self):
286286
self._finalize_tmpdir = weakref.finalize(self, self._tmpdir.cleanup)
287287

288288
# test the LaTeX setup to ensure a clean startup of the subprocess
289-
try:
290-
self._setup_latex_process(expect_reply=False)
291-
except FileNotFoundError as err:
292-
raise RuntimeError(
293-
f"{self.latex.args[0]!r} not found. Install it or change "
294-
f"rcParams['pgf.texsystem'] to an available TeX "
295-
f"implementation.") from err
296-
except OSError as err:
297-
raise RuntimeError(
298-
f"Error starting process {self.latex.args[0]!r}") from err
289+
self._setup_latex_process(expect_reply=False)
299290
stdout, stderr = self.latex.communicate("\n\\makeatletter\\@@end\n")
300291
if self.latex.returncode != 0:
301292
raise LatexError(
302293
f"LaTeX errored (probably missing font or error in preamble) "
303294
f"while processing the following input:\n"
304295
f"{self._build_latex_header()}",
305296
stdout)
306-
307297
self.latex = None # Will be set up on first use.
308298
# Per-instance cache.
309299
self._get_box_metrics = functools.lru_cache()(self._get_box_metrics)
@@ -317,15 +307,28 @@ def _setup_latex_process(self, *, expect_reply=True):
317307
# Open LaTeX process for real work; register it for deletion. On
318308
# Windows, we must ensure that the subprocess has quit before being
319309
# able to delete the tmpdir in which it runs; in order to do so, we
320-
# must first `kill()` it, and then `communicate()` with it.
321-
self.latex = subprocess.Popen(
322-
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
323-
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
324-
encoding="utf-8", cwd=self.tmpdir)
310+
# must first `kill()` it, and then `communicate()` with or `wait()` on
311+
# it.
312+
try:
313+
self.latex = subprocess.Popen(
314+
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
315+
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
316+
encoding="utf-8", cwd=self.tmpdir)
317+
except FileNotFoundError as err:
318+
raise RuntimeError(
319+
f"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change "
320+
f"rcParams['pgf.texsystem'] to an available TeX implementation"
321+
) from err
322+
except OSError as err:
323+
raise RuntimeError(
324+
f"Error starting {mpl.rcParams['pgf.texsystem']!r}") from err
325325

326326
def finalize_latex(latex):
327327
latex.kill()
328-
latex.communicate()
328+
try:
329+
latex.communicate()
330+
except RuntimeError:
331+
latex.wait()
329332

330333
self._finalize_latex = weakref.finalize(
331334
self, finalize_latex, self.latex)

lib/matplotlib/tests/test_colors.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
import itertools
33
import unittest.mock
4+
from packaging.version import parse as parse_version
45

56
from io import BytesIO
67
import numpy as np
@@ -146,9 +147,13 @@ def test_double_register_builtin_cmap():
146147
with pytest.raises(ValueError, match='A colormap named "viridis"'):
147148
with pytest.warns(mpl.MatplotlibDeprecationWarning):
148149
cm.register_cmap(name, mpl.colormaps[name])
149-
with pytest.warns(UserWarning):
150-
# TODO is warning more than once!
151-
cm.register_cmap(name, mpl.colormaps[name], override_builtin=True)
150+
151+
if parse_version(pytest.__version__).major < 8:
152+
with pytest.warns(UserWarning):
153+
cm.register_cmap(name, mpl.colormaps[name], override_builtin=True)
154+
else:
155+
with pytest.warns(UserWarning), pytest.warns(mpl.MatplotlibDeprecationWarning):
156+
cm.register_cmap(name, mpl.colormaps[name], override_builtin=True)
152157

153158

154159
def test_unregister_builtin_cmap():

lib/matplotlib/tests/test_rcparams.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ def test_rcparams_update():
107107
rc = mpl.RcParams({'figure.figsize': (3.5, 42)})
108108
bad_dict = {'figure.figsize': (3.5, 42, 1)}
109109
# make sure validation happens on input
110-
with pytest.raises(ValueError), \
111-
pytest.warns(UserWarning, match="validate"):
110+
with pytest.raises(ValueError):
112111
rc.update(bad_dict)
113112

114113

115114
def test_rcparams_init():
116-
with pytest.raises(ValueError), \
117-
pytest.warns(UserWarning, match="validate"):
115+
with pytest.raises(ValueError):
118116
mpl.RcParams({'figure.figsize': (3.5, 42, 1)})
119117

120118

lib/matplotlib/tests/test_ticker.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import locale
44
import logging
55
import re
6+
from packaging.version import parse as parse_version
67

78
import numpy as np
89
from numpy.testing import assert_almost_equal, assert_array_equal
@@ -730,10 +731,17 @@ def test_mathtext_ticks(self):
730731
'axes.formatter.use_mathtext': False
731732
})
732733

733-
with pytest.warns(UserWarning, match='cmr10 font should ideally'):
734-
fig, ax = plt.subplots()
735-
ax.set_xticks([-1, 0, 1])
736-
fig.canvas.draw()
734+
if parse_version(pytest.__version__).major < 8:
735+
with pytest.warns(UserWarning, match='cmr10 font should ideally'):
736+
fig, ax = plt.subplots()
737+
ax.set_xticks([-1, 0, 1])
738+
fig.canvas.draw()
739+
else:
740+
with pytest.warns(UserWarning, match="Glyph 8722"), \
741+
pytest.warns(UserWarning, match='cmr10 font should ideally'):
742+
fig, ax = plt.subplots()
743+
ax.set_xticks([-1, 0, 1])
744+
fig.canvas.draw()
737745

738746
def test_cmr10_substitutions(self, caplog):
739747
mpl.rcParams.update({

src/_macosx.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ int mpl_check_modifier(
547547
close(channel[0]);
548548
}
549549

550+
Py_BEGIN_ALLOW_THREADS
551+
550552
NSDate* date =
551553
(timeout > 0.0) ? [NSDate dateWithTimeIntervalSinceNow: timeout]
552554
: [NSDate distantFuture];
@@ -559,6 +561,8 @@ int mpl_check_modifier(
559561
[NSApp sendEvent: event];
560562
}
561563

564+
Py_END_ALLOW_THREADS
565+
562566
if (py_sigint_handler) { PyOS_setsig(SIGINT, py_sigint_handler); }
563567
if (sigint_socket) { CFSocketInvalidate(sigint_socket); }
564568
if (!error) { close(channel[1]); }

0 commit comments

Comments
 (0)
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