Skip to content

Commit a377ba0

Browse files
committed
fix cython part
1 parent 6e37b9f commit a377ba0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

logwrap/log_wrap.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ cdef:
4848
cpdef str post_process_param(self, object arg, str arg_repr)
4949

5050
cdef:
51+
str _safe_val_repr(self, object value)
5152
str _get_func_args_repr(self, sig: inspect.Signature, tuple args, dict kwargs)
5253
void _make_done_record(self, logger: logging.Logger, str func_name, result: typing.Any) except *
5354
void _make_calling_record(self, logger: logging.Logger, str name, str arguments, str method=?) except *

logwrap/log_wrap.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,23 @@ cdef class LogWrap(class_decorator.BaseDecorator):
319319
return arg_repr
320320

321321
cdef:
322-
str _safe_val_repr(self, value: typing.Any):
322+
str _safe_val_repr(self, object value: typing.Any):
323323
"""Try to get repr for value and provide fallback text in case of impossibility.
324324
325325
:param value: value to try make repr
326326
:type value: typing.Any
327327
:return: repr string or fallback description
328328
:rtype: str
329329
"""
330+
cdef:
331+
str base_name = getattr(value, "name", getattr(value, "__name__", value.__class__.__name__))
332+
str base_details
330333
try:
331334
return repr_utils.pretty_repr(
332335
src=value, indent=INDENT + 4, no_indent_start=True, max_indent=self.max_indent
333336
)
334337
except Exception as exc:
335-
cdef:
336-
str base_name = getattr(value, "name", getattr(value, "__name__", value.__class__.__name__))
337-
str base_details = f"at 0x{id(value):X} (repr failed with reason: {exc})"
338+
base_details = f"at 0x{id(value):X} (repr failed with reason: {exc})"
338339

339340
if isinstance(value, types.FunctionType):
340341
return f"<function {base_name} {base_details}>"

0 commit comments

Comments
 (0)