Skip to content

Commit

Permalink
remove f strings and check for stack fail
Browse files Browse the repository at this point in the history
  • Loading branch information
laves committed Oct 6, 2023
1 parent c1bf007 commit bb0a381
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions binding/python/_porcupine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def __init__(self, message: str = '', message_stack: Sequence[str] = None):
def __str__(self):
message = self._message
if len(self._message_stack) == 0:
return f'{message}.'
return '%s.' % message
else:
message += ':'
for i in range(len(self._message_stack)):
message += f'\n [{i}] {self._message_stack[i]}'
message += '\n [%d] %s' % (i, self._message_stack[i])
return message

@property
Expand Down Expand Up @@ -171,7 +171,7 @@ def __init__(

self._get_error_stack_func = library.pv_get_error_stack
self._get_error_stack_func.argtypes = [POINTER(POINTER(c_char_p)), POINTER(c_int)]
self._get_error_stack_func.restype = None
self._get_error_stack_func.restype = self.PicovoiceStatuses

self._free_error_stack_func = library.pv_free_error_stack
self._free_error_stack_func.argtypes = [POINTER(c_char_p)]
Expand Down Expand Up @@ -267,7 +267,9 @@ def sample_rate(self) -> int:
def _get_error_stack(self) -> Sequence[str]:
message_stack_ref = POINTER(c_char_p)()
message_stack_depth = c_int()
self._get_error_stack_func(byref(message_stack_ref), byref(message_stack_depth))
status = self._get_error_stack_func(byref(message_stack_ref), byref(message_stack_depth))
if status is not self.PicovoiceStatuses.SUCCESS:
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status](message='Unable to get Porcupine error state')

message_stack = list()
for i in range(message_stack_depth.value):
Expand Down

0 comments on commit bb0a381

Please sign in to comment.