Exception Attributes
UnicodeError.object — exception attribute
Inspect the original failing input. For decoding it is typically bytes, while encoding and translation use text. The object may be larger than the failing slice; use start and end to isolate the relevant segment. Avoid logging private input.
Formal Syntax & Structure
python syntaxpython
error.objectReturn Value
bytes | str
Metadata on the concrete Unicode exception, when applicable.
Working Example
Example Snippetpython
try: b"A\xffB".decode("utf-8")except UnicodeDecodeError as error: print(error.object)