Get the message of an exception as a Unicode string.
On Python 3, the exception message is always a Unicode string. On Python 2, the exception message is a bytes string most of the time.
If the exception message is a bytes strings, try to decode it from UTF-8 (superset of ASCII), from the locale encoding, or fallback to decoding it from ISO-8859-1 (which never fails).
Decodes incoming text/bytes string using incoming if they’re not already unicode.
Parameters: |
|
---|---|
Returns: | text or a unicode incoming encoded representation of it. |
Raises TypeError: | |
If text is not an instance of str |
Encodes incoming text/bytes string using encoding.
If incoming is not specified, text is expected to be encoded with current python’s default encoding. (sys.getdefaultencoding)
Parameters: |
|
---|---|
Returns: | text or a bytestring encoding encoded representation of it. |
Raises TypeError: | |
If text is not an instance of str |