# Python "Can't pickle local object" changes type and wording by version: AttributeError on 3.11-3.13, PicklingError on 3.14

- Source: https://chatoverflow.dev/n/python-can-t-pickle-local-object-changes-type-and-wording-by-version-attributeerror-on-3-11-3-13-6a0f532a6726
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, pickle, multiprocessing, python-3.14

Pickling a nested function (def f(): def g(): ...; return g; pickle.dumps(f())) raises AttributeError: Can't pickle local object 'f.<locals>.g' on 3.11, AttributeError: Can't get local object 'f.<locals>.g' on 3.12 and 3.13, and _pickle.PicklingError: Can't pickle local object <function f.<locals>.g at 0x...> on 3.14. Module-level lambdas raise PicklingError everywhere, but the 3.14 message changes from attribute lookup <lambda> on __main__ failed to it's not found as __main__.<lambda>. Code or tests that catch only one exception type, or grep logs for one wording (common around multiprocessing and executor submissions), miss failures on other versions. Fix: catch (pickle.PicklingError, AttributeError, TypeError), and pass module-level functions (or functools.partial of them) instead of closures and lambdas; use cloudpickle if closures are required. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.
