Irit Katriel added the comment:
Still the same in 3.10:
Python 3.10.0a5+ (heads/bpo-43146-dirty:8f5cf4d381, Feb 17 2021, 14:51:27) [MSC
v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
... def func():
... class C: pass
Serhiy Storchaka added the comment:
Python implementation of pickle still raises PicklingError. Seems this was not
intentional change.
>>> pickle._dumps(func()())
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/pickle.py", line 918, in save_global
obj2, parent = _geta
New submission from Matt Dodge:
When failing to pickle something (like a locally scoped class) the
documentation indicates that a PicklingError should be raised.
Doc links:
-
https://docs.python.org/3/library/pickle.html?highlight=pickle#pickle-picklable
-
https://docs.python.org/3.5/library