From: Val Date: Sat, 25 Jul 2020 12:22:10 +0000 (-0400) Subject: Update code to work with pickling (#327) X-Git-Tag: v0.27~16 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=619ba26dfe5aadb755c56b015a7318eae982f125;p=pyelftools.git Update code to work with pickling (#327) --- diff --git a/elftools/construct/core.py b/elftools/construct/core.py index 214c58f..14a50f8 100644 --- a/elftools/construct/core.py +++ b/elftools/construct/core.py @@ -345,7 +345,7 @@ class FormatField(StaticField): return attrs def __setstate__(self, attrs): attrs["packer"] = Packer(attrs["packer"]) - return StaticField.__setstate__(attrs) + return StaticField.__setstate__(self, attrs) def _parse(self, stream, context): try: return self.packer.unpack(_read_stream(stream, self.length))[0] @@ -1297,6 +1297,8 @@ class Pass(Construct): assert obj is None def _sizeof(self, context): return 0 + def __reduce__(self): + return self.__class__.__name__ Pass = Pass(None) class Terminator(Construct):