Return a size-limited safe repr-string for the given object. Failing __repr__ functions of user instances will be represented with a short exception info and 'saferepr' generally takes care to never raise exceptions itself. This function is a wrapper around the Repr/reprlib functio
(
obj: object, maxsize: int | None = DEFAULT_REPR_MAX_SIZE, use_ascii: bool = False
)
| 122 | |
| 123 | |
| 124 | def saferepr( |
| 125 | obj: object, maxsize: int | None = DEFAULT_REPR_MAX_SIZE, use_ascii: bool = False |
| 126 | ) -> str: |
| 127 | """Return a size-limited safe repr-string for the given object. |
| 128 | |
| 129 | Failing __repr__ functions of user instances will be represented |
| 130 | with a short exception info and 'saferepr' generally takes |
| 131 | care to never raise exceptions itself. |
| 132 | |
| 133 | This function is a wrapper around the Repr/reprlib functionality of the |
| 134 | stdlib. |
| 135 | """ |
| 136 | return SafeRepr(maxsize, use_ascii).repr(obj) |
| 137 | |
| 138 | |
| 139 | def saferepr_unlimited(obj: object, use_ascii: bool = True) -> str: |