diff options
author | José Fonseca <jfonseca@vmware.com> | 2014-06-20 14:12:19 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2014-06-24 16:30:34 +0100 |
commit | 66b7bcc2be115fb1528b6bdf75798e60cc59721f (patch) | |
tree | 0ef0efc74bf57c9916d1cf1d62823c02340f1824 /scripts | |
parent | 01fc85bb71cb7518f17ca789429f137727970737 (diff) |
cli/pickle: Treat pointers specially.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/unpickle.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/unpickle.py b/scripts/unpickle.py index 5fe40f59..1932497e 100755 --- a/scripts/unpickle.py +++ b/scripts/unpickle.py @@ -55,6 +55,17 @@ CALL_FLAG_MARKER_PUSH = (1 << 9) CALL_FLAG_MARKER_POP = (1 << 10) +class Pointer(int): + + def __str__(self): + if self == 0: + return 'NULL' + else: + return hex(self) + + __repr__ = __str__ + + class Visitor: def __init__(self): @@ -69,9 +80,10 @@ class Visitor: self.dispatch[list] = self.visitList self.dispatch[dict] = self.visitDict self.dispatch[bytearray] = self.visitByteArray + self.dispatch[Pointer] = self.visitPointer def visit(self, obj): - method = self.dispatch.get(type(obj), self.visitObj) + method = self.dispatch.get(obj.__class__, self.visitObj) return method(obj) def visitObj(self, obj): @@ -110,6 +122,9 @@ class Visitor: def visitByteArray(self, obj): raise NotImplementedError + def visitPointer(self, obj): + return self.visitAtom(obj) + class Dumper(Visitor): |