The pickling of local function from a module is broken on python3.4. This seems to be related to #205
The way to reproduce that is having 2 files in the same directory and launching the later command line.
mk_dynamic.py
def f():
def g():
return sum(range(10))
return g
main.py
from mk_dynamic import f
from cloudpickle import dumps
print(dumps(f()))
And then calling the pickled function with the following command line
python -c "from cloudpickle import loads; g = loads($(python main.py)); print(g())"
The given output is
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/tom/Work/prog/stackoverflow/bug_cloudpickle_builtins/mk_nobuiltin.py", line 5, in g
return sum(range(10))
KeyError: 'sum'