File py314.patch of Package python-cloudpickle
From c025de75715cd2f22f650d1b4bbb8559e8eaac46 Mon Sep 17 00:00:00 2001
From: Thomas Moreau <thomas.moreau.2010@gmail.com>
Date: Tue, 25 Mar 2025 10:32:53 +0100
Subject: [PATCH] MTN skip test with recursion limit on python3.14 due to
segfault on OSX (#561)
---
tests/cloudpickle_test.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Index: cloudpickle-3.1.1/tests/cloudpickle_test.py
===================================================================
--- cloudpickle-3.1.1.orig/tests/cloudpickle_test.py
+++ cloudpickle-3.1.1/tests/cloudpickle_test.py
@@ -2507,19 +2507,19 @@ class CloudPickleTest(unittest.TestCase)
inner_func = depickled_factory()
assert inner_func() == _TEST_GLOBAL_VARIABLE
+ # TODO: remove this xfail when we drop support for Python 3.8. We don't
+ # plan to fix it because Python 3.8 is EOL.
@pytest.mark.skipif(
sys.version_info < (3, 9),
reason="Can cause CPython 3.8 to segfault",
)
- # TODO: remove this xfail when we drop support for Python 3.8. We don't
- # plan to fix it because Python 3.8 is EOL.
def test_recursion_during_pickling(self):
class A:
def __getattribute__(self, name):
return getattr(self, name)
a = A()
- with pytest.raises(pickle.PicklingError, match="recursion"):
+ with pytest.raises(pickle.PicklingError, match="deep recursion"):
cloudpickle.dumps(a)
def test_out_of_band_buffers(self):
Index: cloudpickle-3.1.1/cloudpickle/cloudpickle.py
===================================================================
--- cloudpickle-3.1.1.orig/cloudpickle/cloudpickle.py
+++ cloudpickle-3.1.1/cloudpickle/cloudpickle.py
@@ -1301,12 +1301,9 @@ class Pickler(pickle.Pickler):
def dump(self, obj):
try:
return super().dump(obj)
- except RuntimeError as e:
- if len(e.args) > 0 and "recursion" in e.args[0]:
- msg = "Could not pickle object as excessively deep recursion required."
- raise pickle.PicklingError(msg) from e
- else:
- raise
+ except RecursionError as e:
+ msg = "Could not pickle object as excessively deep recursion required."
+ raise pickle.PicklingError(msg) from e
def __init__(self, file, protocol=None, buffer_callback=None):
if protocol is None: