module documentation

Provisional module to handle Exceptions across Python versions.

This module will be deprecated with the end of support for Python 2.7 and be removed in Docutils 1.2.

Error reporting should be safe from encoding/decoding errors. However, implicit conversions of strings and exceptions like

>>> u'%s world: %s' % ('Hällo', Exception(u'Hällo')

fail in some Python versions:

  • In Python <= 2.6, unicode(<exception instance>) uses __str__ and fails with non-ASCII chars in`unicode` arguments. (work around http://bugs.python.org/issue2517):
  • In Python 2, unicode(<exception instance>) fails, with non-ASCII chars in arguments. (Use case: in some locales, the errstr argument of IOError contains non-ASCII chars.)
  • In Python 2, str(<exception instance>) fails, with non-ASCII chars in unicode arguments.

The SafeString, ErrorString and ErrorOutput classes handle common exceptions.

Class ​Error​Output Wrapper class for file-like error streams with failsafe de- and encoding of str, bytes, unicode and Exception instances.
Class ​Error​String Safely report exception type and message.
Class ​Safe​String A wrapper providing robust conversion to str and unicode.
Variable locale​_encoding Undocumented
locale_encoding =

Undocumented