diff --git a/bindings/python/README b/bindings/python/README index 7bd0762c..0d54b590 100644 --- a/bindings/python/README +++ b/bindings/python/README @@ -3,10 +3,16 @@ $ sudo make install For better performance, install Cython-based binding with: - (NOTE: you must have Cython installed in your machine first) $ sudo make install_cython + NOTE: to install Cython, depending on if you already have pip or + easy_install installed, simply do either: + + $ sudo pip install cython + or: + $ sudo pip install cython + This directory contains some test code to show how to use Capstone API. diff --git a/bindings/python/capstone/capstone.py b/bindings/python/capstone/capstone.py index 5c89304c..29d41f69 100644 --- a/bindings/python/capstone/capstone.py +++ b/bindings/python/capstone/capstone.py @@ -291,21 +291,24 @@ class CsInsn(object): if self._cs._detail: detail = self._raw.detail.contents return detail.regs_read[:detail.regs_read_count] - return None + + raise CsError(CS_ERR_DETAIL) @property def regs_write(self): if self._cs._detail: detail = self._raw.detail.contents return detail.regs_write[:detail.regs_write_count] - return None + + raise CsError(CS_ERR_DETAIL) @property def groups(self): if self._cs._detail: detail = self._raw.detail.contents return detail.groups[:detail.groups_count] - return None + + raise CsError(CS_ERR_DETAIL) def __gen_detail(self): arch = self._cs.arch @@ -327,6 +330,9 @@ class CsInsn(object): ppc.get_arch_info(detail.arch.ppc) def __getattr__(self, name): + if not self._cs._detail: + raise CsError(CS_ERR_DETAIL) + attr = object.__getattribute__ if not attr(self, '_cs')._detail: return None @@ -394,7 +400,7 @@ class Cs(object): else: self._syntax = None - self._detail = True # by default, get instruction details + self._detail = False # by default, do not produce instruction details def __del__(self): if self.csh: