all Python 3Exceptionsexception
UnicodeTranslateError
built-in exceptions
An error while translating Unicode characters (rare).
Syntax
raise UnicodeTranslateError
You will almost never meet it in ordinary code: the object exists so that error handlers registered through codecs.register_error can tell the translation case apart from encoding and decoding. Unlike its siblings, the constructor takes four arguments and no encoding — just object, start, end and reason. There is no reason to write a dedicated except clause for it in coursework.
Examples
try:
raise UnicodeTranslateError('x', 0, 1, 'reason')
except UnicodeTranslateError as e:
print(type(e).__name__) # → UnicodeTranslateError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy