Force pc argument to add_hook to be an int or None (#30)

* force pc to be an int or None

* follow pep8 more closely

* change debug message to an error

* use format and isinstance
This commit is contained in:
JP Smith 2017-02-27 14:25:18 -06:00 committed by GitHub
parent bbc36a2b2e
commit 98567efeaa

View File

@ -310,7 +310,10 @@ class Manticore(object):
Add a callback to be invoked on executing a program counter. Pass 'None'
for pc to invoke callback on every instruction.
'''
self._hooks.setdefault(pc, set()).add(callback)
if not (isinstance(pc, (int, long)) or pc is None):
raise TypeError("pc must be either an int or None, not {}".format(pc.__class__.__name__))
else:
self._hooks.setdefault(pc, set()).add(callback)
def _get_symbol_address(self, symbol):
'''