HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/docutils/utils/__pycache__/error_reporting.cpython-36.opt-1.pyc
3

w2�e� �"@s�dZddlZddlZyddlZWnek
r8dZYn�Xyej�dpRej�dZWnDek
r�Z	zde	j
krxdZndZWYddZ	[	XndZYnXyejep�d�Wnek
r�dZYnXGdd�de
�ZGd	d
�d
e�ZGdd�de
�ZdS)
u�
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.
�N�zunknown locale: UTF-8zUTF-8�c@s*eZdZdZddd�Zdd�Zd	d
�ZdS)�
SafeStringzG
    A wrapper providing robust conversion to `str` and `unicode`.
    N�backslashreplace�replacecCs0||_|pt|dd�ptpd|_||_||_dS)N�encoding�ascii)�data�getattr�locale_encodingr�encoding_errors�decoding_errors)�selfr	rrr
�r�%/usr/lib/python3.6/error_reporting.py�__init__Hs

zSafeString.__init__cs�y
t�j�Stk
rzt�jt�rF�fdd��jjD�}dj|�St�jt�rttjdkrb�jS�jj	�j
�j�S�YnXdS)Ncs g|]}tt|�j�j���qSr)�strrrr)�.0�arg)rrr�
<listcomp>Vsz&SafeString.__str__.<locals>.<listcomp>z, �r)rr)rr	�UnicodeEncodeError�
isinstance�	Exception�args�join�sys�version_info�encoderr)rrr)rr�__str__Qs




zSafeString.__str__cs�y&t�j�}t�jt�r$|jdd�}|Stk
r�}z�t�jt�rvd�jjt�jj�j	�j
�t�jj�j	�j
�fSt�jt�r��fdd��jj
D�}dj|�St|t�r�t�j�j	�j
�S�WYdd}~XnXdS)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 %s] %s: '%s'cs"g|]}tt|�j�jd���qS))r
)rrrr
)rr)rrrr{sz*SafeString.__unicode__.<locals>.<listcomp>z, N)rr	r�EnvironmentErrorr�UnicodeError�errnor�strerrorrr
�filenamerrr�UnicodeDecodeError)r�u�errorrr)rr�__unicode__bs&



zSafeString.__unicode__)Nrr)�__name__�
__module__�__qualname__�__doc__rrr(rrrrrCs

rcs,eZdZdZ�fdd�Z�fdd�Z�ZS)�ErrorStringz3
    Safely report exception type and message.
    csd|jjjtt|�j�fS)Nz%s: %s)r	�	__class__r)�superr-r)r)r.rrr�s
zErrorString.__str__csd|jjjtt|�j�fS)Nz%s: %s)r	r.r)r/r-r()r)r.rrr(�s
zErrorString.__unicode__)r)r*r+r,rr(�
__classcell__rr)r.rr-�sr-c@s*eZdZdZddd�Zdd�Zd	d
�ZdS)�ErrorOutputz�
    Wrapper class for file-like error streams with
    failsave de- and encoding of `str`, `bytes`, `unicode` and
    `Exception` instances.
    NrrcCs~|dkrtj}n>|sd}n4t|t�r0t|d�}nt|t�rNt|jtj��d�}||_|pjt|dd�pjt	pjd|_
||_||_dS)a�
        :Parameters:
            - `stream`: a file-like object,
                        a string (path to a file),
                        `None` (write to `sys.stderr`, default), or
                        evaluating to `False` (write() requests are ignored).
            - `encoding`: `stream` text encoding. Guessed if None.
            - `encoding_errors`: how to treat encoding errors.
        NF�wrr)
r�stderrrr�openr�getfilesystemencoding�streamr
rrrr
)rr6rrr
rrrr�s


zErrorOutput.__init__cCs�|jdkrdSt|t�r0tt||j|j|j��}y|jj|�Wn�t	k
rl|jj|j
|j|j��Ynttk
r�t|t�r�|jj|j
|j|j��dS|jtj
tjfkr�|jjj|�n|jjt||j|j��YnXdS)z�
        Write `data` to self.stream. Ignore, if self.stream is False.

        `data` can be a `string`, `unicode`, or `Exception` instance.
        FN)r6rrrrrrr
�writerr�	TypeErrorrr3�stdout�buffer)rr	rrrr7�s$




zErrorOutput.writecCs>|jtjtjfkrdSy|jj�Wntk
r8YnXdS)z�
        Close the error-output stream.

        Ignored if the stream is` sys.stderr` or `sys.stdout` or has no
        close() method.
        N)r6rr9r3�close�AttributeError)rrrrr;�szErrorOutput.close)NNrr)r)r*r+r,rr7r;rrrrr1�s
!r1)r,r�codecsZlocale�ImportErrorrZ	getlocaleZgetdefaultlocale�
ValueErrorr'r�lookup�LookupError�objectrr-r1rrrr�<module>#s(



@