Skip to content

Instantly share code, notes, and snippets.

@ironpythonbot
Created December 9, 2014 17:54
Show Gist options
  • Save ironpythonbot/5991bea58d67bd5a5269 to your computer and use it in GitHub Desktop.
Save ironpythonbot/5991bea58d67bd5a5269 to your computer and use it in GitHub Desktop.
CodePlex Issue #30805 Plain Text Attachments
import pickle
class MyClass(object):
pass
def test(obj):
# add a custom attribute
obj.some_attribute=42
print "reduce=",obj.__reduce__() # doesn't include the attribute...
o=pickle.loads(pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL))
print "some_attribute=",o.some_attribute # crashes with AttributeError...
print "test with MyClass..."
test(MyClass())
print "test with Exception..."
test(Exception("some exception"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment