Repository navigation
Description
We are already building RPM packages with Python 3.15 alpha 7 in Fedora Linux and I've found some issues and solutions for them.
call_count in Mock
Since python/cpython@850f95f, call_count is now calculated property, so setting call_count = 0 in tests does not work as before and does not actually reset the counter.
My solution for test_norma_callback:
--- a/lib/matplotlib/tests/test_colors.py
+++ b/lib/matplotlib/tests/test_colors.py
@@ -1590,7 +1590,9 @@ def test_norm_callback():
assert increment.call_count == 2
# We only want autoscale() calls to send out one update signal
- increment.call_count = 0
+ # Python 3.15: Mock.call_count is now a computed property based on
+ # len(call_args_list), so setting call_count=0 no longer works.
+ increment.reset_mock()
norm.autoscale([0, 1, 2])
assert increment.call_count == 1tolerances
I have to increase tolerances in test_pcolornearestunits and test_rcupdate – I don't know whether this is realted to Python 3.15 or not though.
--- a/lib/matplotlib/tests/test_axes.py
+++ b/lib/matplotlib/tests/test_axes.py
@@ -1668,7 +1668,7 @@ def test_pcolornearest(fig_test, fig_ref):
ax.pcolormesh(x2, y2, Z, shading='nearest')
-@check_figures_equal(extensions=["png"])
+@check_figures_equal(extensions=["png"], tol=5.0)
def test_pcolornearestunits(fig_test, fig_ref):
ax = fig_test.subplots()
x = [datetime.datetime.fromtimestamp(x * 3600) for x in range(10)]and
--- a/lib/matplotlib/tests/test_backend_pgf.py
+++ b/lib/matplotlib/tests/test_backend_pgf.py
@@ -131,7 +131,7 @@ def test_rcupdate():
'pgf.preamble': ('\\usepackage[utf8x]{inputenc}'
'\\usepackage[T1]{fontenc}'
'\\usepackage{sfmath}')}]
- tol = [0, 13.2] if _old_gs_version else [0, 0]
+ tol = [0, 13.2] if _old_gs_version else [0, 5.0] # Increased tolerance for Python 3.15
for i, rc_set in enumerate(rc_sets):
with mpl.rc_context(rc_set):
for substring, pkg in [('sfmath', 'sfmath'), ('utf8x', 'ucs')]:Silenced deprecation warnings
I have to silence gi.PyGIDeprecationWarning: GLib.unix_signal_add_full is deprecated; use GLibUnix.signal_add_full instead and DeprecationWarning: This process (pid=13234) is multi-threaded, use of fork() may lead to deadlocks in the child.. Only the second one is coming from Python itself but both might be important for new releases of matplotlib.
--- a/lib/matplotlib/tests/test_backend_gtk3.py
+++ b/lib/matplotlib/tests/test_backend_gtk3.py
@@ -6,6 +6,8 @@ from unittest import mock
@pytest.mark.backend("gtk3agg", skip_on_importerror=True)
+@pytest.mark.filterwarnings("ignore:.*unix_signal_add_full.*:gi.PyGIDeprecationWarning")
+@pytest.mark.filterwarnings("ignore:.*unix_signal_add_full.*:DeprecationWarning")
def test_correct_key():
pytest.xfail("test_widget_send_event is not triggering key_press_event")
and
--- a/lib/matplotlib/tests/test_font_manager.py
+++ b/lib/matplotlib/tests/test_font_manager.py
@@ -230,6 +230,9 @@ def _model_handler(_):
@pytest.mark.skipif(not hasattr(os, "register_at_fork"),
reason="Cannot register at_fork handlers")
+# Python 3.15+ raises DeprecationWarning for fork in multi-threaded process
+@pytest.mark.filterwarnings("ignore:.*multi-threaded.*fork.*:DeprecationWarning")
+@pytest.mark.filterwarnings("ignore:.*multi-threaded.*fork.*:RuntimeWarning")
def test_fork():
_model_handler(0) # Make sure the font cache is filled.
ctx = multiprocessing.get_context("fork")
Activity
timhoffm commentedon Mar 31, 2026
Thanks for the report.
call_count - PR welcome
tolerances - we need to investigate the image differences
deprecation warnings - the first one is #31398; multi-threaded.fork needs separate investigation
jklymak commentedon Mar 31, 2026
Yes, a tolerance of 5 is quite high - the largest in this file is 1.28, and even that seems suspicious. It would be helpful if you could generate the two images and post to make sure things are working. It's possible the test needs to be changed (perhaps due to different ticks being found), or that there is an actual bug.
QuLogic commentedon Mar 31, 2026
The first issue is already fixed in #31153 and will be in the next release.
frenzymadness commentedon Apr 7, 2026
Ok, so for the
test_pcolornearest, the 5 % tolerance is likely too much, as the images do not differ that much.frenzymadness commentedon Apr 7, 2026
The same applies to rcupdate where the difference is not 0 but again very small:
QuLogic commentedon Apr 8, 2026
Are you sure that latter one is Python 3.15 and not a new Ghostscript release? It seems odd that a Python update would make such a difference at all.
frenzymadness commentedon Apr 8, 2026
No, it does not seem to be related to Python 3.15.
QuLogic commentedon Apr 21, 2026
I can only reproduce the callback and fork issue on Python 3.15 alpha in Fedora 43. The others are probably other dependencies, most likely Ghostscript.
befeleme commentedon May 21, 2026
I am testing matplotlib currently with Python 3.15.0b1 and see two more test failures not reported yet:
There's an issue with timezones in test_auto_date_locator:
And an issue related to the default pprint output being changed:
QuLogic commentedon May 29, 2026
This one is #31780.
befeleme commentedon Jun 4, 2026
FTR, test_RcParams_class will probably not need changes in the end, as previous pprint defaults have been restored in beta2 (after community concerns voiced).