diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-12-02 11:33:06 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-12-02 11:33:06 -0500 |
commit | d5f462bbc409a5ce89ad3e1d6045d2d11aae7378 (patch) | |
tree | 87af237c34fd81451d9ce0a18918e8582583c9de | |
parent | 17c50cdac2c35e4f37bc5fd68f24a00d1e7c67a6 (diff) | |
download | cpython-git-d5f462bbc409a5ce89ad3e1d6045d2d11aae7378.tar.gz |
document UnicodeError attributes
-rw-r--r-- | Doc/library/exceptions.rst | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 6c80df7c60..c12e874a39 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -387,6 +387,30 @@ The following exceptions are the exceptions that are actually 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`. + .. versionadded:: 2.0 |