summaryrefslogtreecommitdiffstats
path: root/Doc/library/exceptions.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-12-02 16:33:06 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-12-02 16:33:06 (GMT)
commit78f7e3a8dc999114c6863754b0c72ad5a9ec93eb (patch)
tree4be537a4cfc92459c8c270fb7d868fe2d83fbb7c /Doc/library/exceptions.rst
parent196035595f6002868e0a760d78b7bd9fd630fcbd (diff)
downloadcpython-78f7e3a8dc999114c6863754b0c72ad5a9ec93eb.zip
cpython-78f7e3a8dc999114c6863754b0c72ad5a9ec93eb.tar.gz
cpython-78f7e3a8dc999114c6863754b0c72ad5a9ec93eb.tar.bz2
document UnicodeError attributes
Diffstat (limited to 'Doc/library/exceptions.rst')
-rw-r--r--Doc/library/exceptions.rst24
1 files changed, 24 insertions, 0 deletions
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 053ba56..89f933c 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