Brett Cannon added the comment:
It won't work without the global namespace as pickle needs to be able to figure
out where the function lives (the function itself doesn't get pickled, just the
name of the function).
--
nosy: +brett.cannon
resolution: -> not a bug
stage: -> resolved
st
New submission from Jeff Zhang:
I want to use pickle in compile/exec, but it doesn't work for me. It only works
when I use the global namespace. But I don't want to use global namespace, is
there any way for that ? Thanks
>>> a = compile("def f():\n\t'hello'\nimport pickle\npickle.dumps(f)",