On Fri, Jun 3, 2011 at 5:03 PM, Chris Torek <nos...@torek.net> wrote:
> The real magic is in the unpickler, which has figured out how to
> access shutil.copy without importing shutil into the global namespace:

So from this I gather that it doesn't actually pickle the code, just
the name. Seems a little odd, but that would explain why this didn't
really work:

>>> def asdf(x):
        x.append(len(x))
        return len(x)

>>> pickle.dumps(asdf)
b'\x80\x03c__main__\nasdf\nq\x00.'
>>> asdf=pickle.dumps(asdf)
>>> pickle.loads(asdf)
b'\x80\x03c__main__\nasdf\nq\x00.'
>>> asdf
b'\x80\x03c__main__\nasdf\nq\x00.'

I tried to do the classic - encode something, discard the original,
attempt to decode. Didn't work.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to