From 47211db8fd21c9547c33119111815cb2976caadd Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Tue, 13 Nov 2018 15:59:24 +0100 Subject: [PATCH] Properly re-raise python exceptions from cython --- logwrap/repr_utils.pxd | 6 +++--- logwrap/repr_utils.pyx | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/logwrap/repr_utils.pxd b/logwrap/repr_utils.pxd index 2a9d649..d5f79e0 100644 --- a/logwrap/repr_utils.pxd +++ b/logwrap/repr_utils.pxd @@ -32,9 +32,9 @@ cdef: cpdef int next_indent(self, unsigned int indent, unsigned int multiplier=?) cdef: - str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=?) - str _repr_simple(self, src: typing.Any, unsigned int indent=?, bint no_indent_start=?) - str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix) + str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=?) except * + str _repr_simple(self, src: typing.Any, unsigned int indent=?, bint no_indent_start=?) except * + str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix) except * cpdef str process_element(self, src: typing.Any, unsigned int indent=?, bint no_indent_start=?) diff --git a/logwrap/repr_utils.pyx b/logwrap/repr_utils.pyx index 46d9a10..393f774 100644 --- a/logwrap/repr_utils.pyx +++ b/logwrap/repr_utils.pyx @@ -169,7 +169,7 @@ cdef class PrettyFormat: return indent + multiplier * self.indent_step cdef: - str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=0): + str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=0) except *: """Repr callable object (function or method). :param src: Callable to process @@ -181,7 +181,7 @@ cdef class PrettyFormat: """ raise NotImplementedError() - str _repr_simple(self, src: typing.Any, unsigned int indent=0, bint no_indent_start=False): + str _repr_simple(self, src: typing.Any, unsigned int indent=0, bint no_indent_start=False) except *: """Repr object without iteration. :param src: Source object @@ -195,7 +195,7 @@ cdef class PrettyFormat: """ raise NotImplementedError() - str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix): + str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix) except *: """Repr iterable item. :param nl: newline before item @@ -324,7 +324,7 @@ cdef class PrettyRepr(PrettyFormat): prefix = "u" return "{spc:<{indent}}{prefix}'''{string}'''".format(spc="", indent=indent, prefix=prefix, string=val) - str _repr_simple(self, src: typing.Any, unsigned int indent=0, bint no_indent_start=False): + str _repr_simple(self, src: typing.Any, unsigned int indent=0, bint no_indent_start=False) except *: """Repr object without iteration. :param src: Source object @@ -343,7 +343,7 @@ cdef class PrettyRepr(PrettyFormat): return self._strings_repr(indent=indent, val=src) return "{spc:<{indent}}{val!r}".format(spc="", indent=indent, val=src) - str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=0): + str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=0) except *: """Repr callable object (function or method). :param src: Callable to process @@ -380,7 +380,7 @@ cdef class PrettyRepr(PrettyFormat): spc="", indent=indent, obj=src, args=param_str, annotation=annotation ) - str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix): + str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix) except *: """Repr iterable item. :param nl: newline before item @@ -450,7 +450,7 @@ cdef class PrettyStr(PrettyFormat): val = val.decode(encoding="utf-8", errors="backslashreplace") return "{spc:<{indent}}{string}".format(spc="", indent=indent, string=val) - str _repr_simple(self, src: typing.Any, unsigned int indent=0, bint no_indent_start=False): + str _repr_simple(self, src: typing.Any, unsigned int indent=0, bint no_indent_start=False) except *: """Repr object without iteration. :param src: Source object @@ -469,7 +469,7 @@ cdef class PrettyStr(PrettyFormat): return self._strings_str(indent=indent, val=src) return "{spc:<{indent}}{val!s}".format(spc="", indent=indent, val=src) - str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=0): + str _repr_callable(self, src: typing.Union[types.FunctionType, types.MethodType], unsigned int indent=0) except *: """Repr callable object (function or method). :param src: Callable to process @@ -506,7 +506,7 @@ cdef class PrettyStr(PrettyFormat): spc="", indent=indent, obj=src, args=param_str, annotation=annotation ) - str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix): + str _repr_iterable_item(self, bint nl, str obj_type, str prefix, unsigned int indent, str result, str suffix) except *: """Repr iterable item. :param nl: newline before item