Built-in Exceptions

UnicodeTranslateError — exception class

Reports failure while translating Unicode text. The constructor takes the input string, start, end and reason; unlike codec encode/decode exceptions it has no encoding argument. Ordinary str.translate does not automatically raise this class for every invalid table. The example raises a controlled stand-in to demonstrate handling; it does not cause the real system failure. Catch UnicodeTranslateError when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
UnicodeTranslateError

Return Value

type

The class object UnicodeTranslateError; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
try:    raise UnicodeTranslateError("abc",1,2,"unsupported character")except UnicodeTranslateError as error:    print(type(error).__name__)
Python Reference