o
    �õ±j  ã                   @   sÎ   d dl mZmZmZmZmZmZmZmZ g d¢Z	G dd„ de
ƒZG dd„ deƒZG dd„ deƒZ		dd
ee dedededeeef f
dd„Zeddd�ZG dd„ deƒZdeeeeeef defdd„ZdS )é    )ÚAnyÚDictÚNoReturnÚPatternÚTupleÚTypeÚTypeVarÚUnion)ÚProtocolErrorÚLocalProtocolErrorÚRemoteProtocolErrorÚvalidateÚbytesifyc                   @   s(   e Zd ZdZd	dededdfdd„ZdS )
r
   aM  Exception indicating a violation of the HTTP/1.1 protocol.

    This as an abstract base class, with two concrete base classes:
    :exc:`LocalProtocolError`, which indicates that you tried to do something
    that HTTP/1.1 says is illegal, and :exc:`RemoteProtocolError`, which
    indicates that the remote peer tried to do something that HTTP/1.1 says is
    illegal. See :ref:`error-handling` for details.

    In addition to the normal :exc:`Exception` features, it has one attribute:

    .. attribute:: error_status_hint

       This gives a suggestion as to what status code a server might use if
       this error occurred as part of a request.

       For a :exc:`RemoteProtocolError`, this is useful as a suggestion for
       how you might want to respond to a misbehaving peer, if you're
       implementing a server.

       For a :exc:`LocalProtocolError`, this can be taken as a suggestion for
       how your peer might have responded to *you* if h11 had allowed you to
       continue.

       The default is 400 Bad Request, a generic catch-all for protocol
       violations.

    é�  ÚmsgÚerror_status_hintÚreturnNc                 C   s*   t | ƒtu r
tdƒ‚t | |¡ || _d S )Nz+tried to directly instantiate ProtocolError)Útyper
   Ú	TypeErrorÚ	ExceptionÚ__init__r   )Úselfr   r   © r   ú|/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/h11/_util.pyr   )   s   
zProtocolError.__init__)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚintr   r   r   r   r   r
      s    r
   c                   @   s   e Zd Zdefdd„ZdS )r   r   c                 C   s
   t | _| ‚©N)r   Ú	__class__©r   r   r   r   Ú!_reraise_as_remote_protocol_error<   s   
z4LocalProtocolError._reraise_as_remote_protocol_errorN)r   r   r   r   r#   r   r   r   r   r   ;   s    r   c                   @   s   e Zd ZdS )r   N)r   r   r   r   r   r   r   r   P   s    r   úmalformed dataÚregexÚdatar   Úformat_argsr   c                 G   s,   |   |¡}|s|r|j|Ž }t|ƒ‚| ¡ S r    )Ú	fullmatchÚformatr   Ú	groupdict)r%   r&   r   r'   Úmatchr   r   r   r   T   s   

r   Ú_T_SentinelÚSentinel)Úboundc                       sX   e Zd Zdee dedeedf deee	f de	def‡ fdd	„Z
defd
d„Z‡  ZS )r-   ÚclsÚnameÚbases.Ú	namespaceÚkwdsr   c                    s2   |t fksJ ‚tƒ j| |||fi |¤Ž}||_|S r    )r-   ÚsuperÚ__new__r!   )r/   r0   r1   r2   r3   Úv©r!   r   r   r5   l   s   zSentinel.__new__c                 C   s   | j S r    )r   r"   r   r   r   Ú__repr__x   s   zSentinel.__repr__)r   r   r   r   r,   r   r   r   r   r   r5   r8   Ú__classcell__r   r   r7   r   r-   k   s    ÿþ
ý
üûúÚsc                 C   s>   t | ƒtu r| S t| tƒr|  d¡} t| tƒrtdƒ‚t| ƒS )NÚasciiz#expected bytes-like object, not int)r   ÚbytesÚ
isinstancer   Úencoder   r   )r:   r   r   r   r      s   


r   N)r$   )Útypingr   r   r   r   r   r   r   r	   Ú__all__r   r
   r   r   r<   r   r   r,   r   r-   Ú	bytearrayÚ
memoryviewr   r   r   r   r   r   Ú<module>   s(   ( 	/ÿÿÿÿÿ

þ$