From: Benjamin Peterson Date: Sun, 2 Dec 2012 16:33:06 +0000 (-0500) Subject: document UnicodeError attributes X-Git-Tag: v3.3.1rc1~571 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=78f7e3a8dc999114c6863754b0c72ad5a9ec93eb;p=thirdparty%2FPython%2Fcpython.git document UnicodeError attributes --- diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 053ba562f8f3..89f933c2ae45 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -371,6 +371,30 @@ The following exceptions are the exceptions that are usually raised. Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of :exc:`ValueError`. + :exc:`UnicodeError` has attributes that describe the encoding or decoding + error. For example, ``err.object[err.start:err.end]`` gives the particular + invalid input that the codec failed on. + + .. attribute:: encoding + + The name of the encoding that raised the error. + + .. attribute:: reason + + A string describing the specific codec error. + + .. attribute:: object + + The object the codec was attempting to encode or decode. + + .. attribute:: start + + The first index of invalid data in :attr:`object`. + + .. attribute:: end + + The index after the last invalid data in :attr:`object`. + .. exception:: UnicodeEncodeError