class NavigableString(unicode, PageElement):
def __new__(cls, value):
if isinstance(value, unicode):
return unicode.__new__(cls, value)
return unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)
def __getnewargs__(self):#this line
return (NavigableString.__str__(self),)
Try this:
x = NavigableString('foop')
y = pickle.dumps(x)
z = pickle.loads(y)
print x, z
I.e.: __getnewargs__
tells pickle.dumps
to pickle x
in such a way that a pickle.loads
back from that string will use NavigableString.__new__
with the proper argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With