r8Sy d Z ddlZddlZddlmZ ej ded ej dk re Z
G d d Z G d
de Z G d d
Z
dS )u9
Deprecated module to handle Exceptions across Python versions.
.. warning::
This module is deprecated with the end of support for Python 2.7
and will be removed in Docutils 0.21 or later.
Replacements:
| SafeString -> str
| ErrorString -> docutils.io.error_string()
| ErrorOutput -> docutils.io.ErrorOutput
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()`` uses
`__str__` and fails with non-ASCII chars in`unicode` arguments.
(work around http://bugs.python.org/issue2517):
* In Python 2, unicode() 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() fails, with non-ASCII chars
in `unicode` arguments.
The `SafeString`, `ErrorString` and `ErrorOutput` classes handle
common exceptions.
N)_locale_encodingzThe `docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.
Details with help("docutils.utils.error_reporting"). )
stacklevel r c * e Zd ZdZ ddZd Zd ZdS )
SafeStringzG
A wrapper providing robust conversion to `str` and `unicode`.
Nbackslashreplacereplacec r || _ |pt |dd pt pd| _ || _ || _ d S )Nencodingascii)datagetattrlocale_encodingr
encoding_errorsdecoding_errors)selfr r
r r s ~/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/docutils/utils/error_reporting.py__init__zSafeString.__init__C sL ! 7WT:t%D%D 7+7/6
.. c t j S # t $ r t j t r/ fd j j D }d | cY S t j t r@t j dk r j cY S j
j j cY S w xY w)Nc ` g | ]*}t t |j j +S )strr r
r .0argr s r
z&SafeString.__str__..P sK 3 3 3 JsDM'+';= = > > 3 3 3r , r )
r r UnicodeEncodeError
isinstance Exceptionargsjoinunicodesysversion_infoencoder
r )r r$ s ` r __str__zSafeString.__str__K s ty>>!! $)Y//
'3 3 3 3#'9>3 3 3 yy&&&$)W--
B#f,,9$$$9++DM,0,@B B B B B s AC*1C%CCc t j }t j t r| dd }|S # t
$ r}t j t rad j j dt j j j j
dt j j j j
dcY d}~S t j t r2 fd j j
D }d | cY d}~S t |t r%t j j j
cY d}~S d}~ww xY w) af
Return unicode representation of `self.data`.
Try ``unicode(self.data)``, catch `UnicodeError` and
* if `self.data` is an Exception instance, work around
http://bugs.python.org/issue2517 with an emulation of
Exception.__unicode__,
* else decode with `self.encoding` and `self.decoding_errors`.
z: u'z: 'z[Errno z] 'Nc b g | ]+}t t |j j ,S ))r )r&