Skip to content

Commit

Permalink
More PY3 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
trolldbois committed Jun 7, 2017
1 parent c4bae52 commit 2eccb6d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions haystack/reverse/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def get_predecessors(self, record):
predecessors_label = self.__record_graph.predecessors(hex(record.address))
records = []
for label in predecessors_label:
# FIXME, eradicate all L for PY3 migration
if label[-1] == 'L':
label = label[:-1]
record_addr = int(label, 16)
Expand Down Expand Up @@ -381,7 +382,7 @@ def listStructuresAddresses(self):
return list(map(long, self._list_records().keys()))

def listStructures(self):
return self._list_records().values()
return list(self._list_records().values())

def is_known_address(self, address):
return address in self._structures_addresses
Expand Down Expand Up @@ -459,10 +460,10 @@ def cacheLoad(cls, memory_handler, heap_addr):
try:
with open(context_cache, 'rb') as fin:
ctx = pickle.load(fin)
except EOFError as e:
except (ValueError, EOFError) as e:
os.remove(context_cache)
log.error('Error in the context file. File cleaned. Please restart.')
raise RuntimeError('Error in the context file. File cleaned. Please restart.')
raise IOError('Error in the context file. File cleaned. Please restart.')
log.debug('\t[-] loaded my context from cache')
ctx.config = config
ctx.memory_handler = memory_handler
Expand Down
2 changes: 0 additions & 2 deletions test/haystack/mappings/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ def test_hasRef(self):
self.assertTrue(self.memory_handler.hasRef(int, 0xcafecafe))
self.assertTrue(self.memory_handler.hasRef(float, 0xcafecafe))
self.assertTrue(self.memory_handler.hasRef(str, 0xcafecafe))
# FIXME, where does unicode comes from ?
self.assertFalse(self.memory_handler.hasRef(unicode, 0xcafecafe))
self.assertFalse(self.memory_handler.hasRef(int, 0xdeadbeef))
me = self.memory_handler.getRefByAddr(0xcafecafe)
# multiple refs
Expand Down
3 changes: 1 addition & 2 deletions test/haystack/search/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ def test_refresh(self):
self.assertEqual(validated, True)
self.assertEqual(usual.val1, 0x0aaaaaaa)
self.assertEqual(usual.val2, 0x0ffffff0)
self.assertEqual(usual.txt, 'This a string with a test this is a test '
'string')
self.assertEqual(usual.txt, b'This a string with a test this is a test string')

# so now we got python objects
# that is node 1
Expand Down

0 comments on commit 2eccb6d

Please sign in to comment.