Summary
pickle has changed from raising an AttributeError to PicklingError for functions containing locals in their reduced path. This change is not reflected in the what's new in 3.14 for pickle.
Example
>>> import pickle
>>>
>>> def some_function(a, b):
... def some_inner_function(c, d):
... return a + b + c + d
... pickle.dumps(some_inner_function)
>>>
>>> try:
... some_function(1, 2)
... except AttributeError as e:
... print(e)
Can't pickle local object 'some_function.<locals>.some_inner_function'
on 3.14 this raises _pickle.PicklingError: Can't pickle local object <function some_function.<locals>.some_inner_function at 0x7fb4fd1a3060>
Cf. the CI in this repo for tests on 3.11-3.14.
Impact
Code that expected and caught AttributeError now gets PicklingError
Python versions
Works in 3.11-3.13, changed in 3.14
Resolution
A comment in the changelog, or a reversion to raising an AttributeError
Summary
picklehas changed from raising anAttributeErrortoPicklingErrorfor functions containing locals in their reduced path. This change is not reflected in the what's new in 3.14 forpickle.Example
on 3.14 this raises
_pickle.PicklingError: Can't pickle local object <function some_function.<locals>.some_inner_function at 0x7fb4fd1a3060>Cf. the CI in this repo for tests on 3.11-3.14.
Impact
Code that expected and caught
AttributeErrornow getsPicklingErrorPython versions
Works in 3.11-3.13, changed in 3.14
Resolution
A comment in the changelog, or a reversion to raising an
AttributeError