Skip to content

Commit e8bbede

Browse files
authored
MNT enable 3.14 recursion test+simplify recursion detection (#573)
1 parent f90f78a commit e8bbede

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

cloudpickle/cloudpickle.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,12 +1301,9 @@ def _function_getnewargs(self, func):
13011301
def dump(self, obj):
13021302
try:
13031303
return super().dump(obj)
1304-
except RuntimeError as e:
1305-
if len(e.args) > 0 and "recursion" in e.args[0]:
1306-
msg = "Could not pickle object as excessively deep recursion required."
1307-
raise pickle.PicklingError(msg) from e
1308-
else:
1309-
raise
1304+
except RecursionError as e:
1305+
msg = "Could not pickle object as excessively deep recursion required."
1306+
raise pickle.PicklingError(msg) from e
13101307

13111308
def __init__(self, file, protocol=None, buffer_callback=None):
13121309
if protocol is None:

tests/cloudpickle_test.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,19 +2513,13 @@ def inner_function():
25132513
sys.version_info < (3, 9),
25142514
reason="Can cause CPython 3.8 to segfault",
25152515
)
2516-
@pytest.mark.skipif(
2517-
sys.version_info > (3, 14),
2518-
reason="Can cause CPython 3.14 interpreter to crash",
2519-
# This interpreter crash is reported upstream in
2520-
# https://github.com/python/cpython/issues/131543
2521-
)
25222516
def test_recursion_during_pickling(self):
25232517
class A:
25242518
def __getattribute__(self, name):
25252519
return getattr(self, name)
25262520

25272521
a = A()
2528-
with pytest.raises(pickle.PicklingError, match="recursion"):
2522+
with pytest.raises(pickle.PicklingError, match="deep recursion"):
25292523
cloudpickle.dumps(a)
25302524

25312525
def test_out_of_band_buffers(self):

0 commit comments

Comments
 (0)