관리-도구
편집 파일: error_reporting.cpython-311.pyc
� P�Dg� � � � 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(<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)�_locale_encodingz�The `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 dd�Zd� Zd� ZdS ) � SafeStringzG A wrapper providing robust conversion to `str` and `unicode`. N�backslashreplace�replacec �r � || _ |pt |dd � � pt pd| _ || _ || _ d S )N�encoding�ascii)�data�getattr�locale_encodingr �encoding_errors�decoding_errors)�selfr r r r s �~/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/docutils/utils/error_reporting.py�__init__zSafeString.__init__C sL � ��� �!� 7�W�T�:�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 ��.0�argr s �r � <listcomp>z&SafeString.__str__.<locals>.<listcomp>P sK �� � 3� 3� 3�� �J�s�D�M�'+�';�=� =� >� >� 3� 3� 3r �, r ) r r �UnicodeEncodeError� isinstance� Exception�args�join�unicode�sys�version_info�encoder r )r r$ s ` r �__str__zSafeString.__str__K s� �� � ��t�y�>�>�!��!� � � ��$�)�Y�/�/� '�3� 3� 3� 3�#'�9�>�3� 3� 3�� �y�y����&�&�&��$�)�W�-�-� B��#�f�,�,��9�$�$�$��9�+�+�D�M�,0�,@�B� B� B� B� B�� ���s � �AC�*1C�%C�Cc � � � 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 � � �d�cY 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&