
    Fg-                    J   S r SSKJr  SSKrSSKJr  / SQr " S S\5      r " S	 S
\5      r	 " S S\	5      r
 " S S\	5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      r " S# S$\5      r " S% S&\5      r " S' S(\5      r " S) S*\5      r " S+ S,\5      r " S- S.\5      r " S/ S0\\5      r " S1 S2\\5      rSS3K J!r!J"r"  \" \#" 5       S4S4S4S4S5.S69  g)7a  
:mod:`websockets.exceptions` defines the following hierarchy of exceptions.

* :exc:`WebSocketException`
    * :exc:`ConnectionClosed`
        * :exc:`ConnectionClosedOK`
        * :exc:`ConnectionClosedError`
    * :exc:`InvalidURI`
    * :exc:`InvalidHandshake`
        * :exc:`SecurityError`
        * :exc:`InvalidMessage`
        * :exc:`InvalidStatus`
        * :exc:`InvalidStatusCode` (legacy)
        * :exc:`InvalidHeader`
            * :exc:`InvalidHeaderFormat`
            * :exc:`InvalidHeaderValue`
            * :exc:`InvalidOrigin`
            * :exc:`InvalidUpgrade`
        * :exc:`NegotiationError`
            * :exc:`DuplicateParameter`
            * :exc:`InvalidParameterName`
            * :exc:`InvalidParameterValue`
        * :exc:`AbortHandshake` (legacy)
        * :exc:`RedirectHandshake` (legacy)
    * :exc:`ProtocolError` (Sans-I/O)
    * :exc:`PayloadTooBig` (Sans-I/O)
    * :exc:`InvalidState` (Sans-I/O)
    * :exc:`ConcurrencyError`

    )annotationsN   )lazy_import)WebSocketExceptionConnectionClosedConnectionClosedOKConnectionClosedError
InvalidURIInvalidHandshakeSecurityErrorInvalidStatusInvalidHeaderInvalidHeaderFormatInvalidHeaderValueInvalidMessageInvalidOriginInvalidUpgradeNegotiationErrorDuplicateParameterInvalidParameterNameInvalidParameterValueProtocolErrorPayloadTooBigInvalidStateConcurrencyErrorc                      \ rS rSrSrSrg)r   A   z7
Base class for all exceptions defined by websockets.

 N__name__
__module____qualname____firstlineno____doc____static_attributes__r       f/Users/admin/workspace/ai/PDFMathTranslate/myenv/lib/python3.13/site-packages/websockets/exceptions.pyr   r   A       r&   r   c                  h    \ rS rSrSr S	       S
S jjrSS jr\SS j5       r\SS j5       r	Sr
g)r   H   a  
Raised when trying to interact with a closed connection.

Attributes:
    rcvd: If a close frame was received, its code and reason are available
        in ``rcvd.code`` and ``rcvd.reason``.
    sent: If a close frame was sent, its code and reason are available
        in ``sent.code`` and ``sent.reason``.
    rcvd_then_sent: If close frames were received and sent, this attribute
        tells in which order this happened, from the perspective of this
        side of the connection.

Nc                    Xl         X l        X0l        U R                  S L U R                   S L =(       d    U R                  S L :X  d   eg Nrcvdsentrcvd_then_sent)selfr.   r/   r0   s       r'   __init__ConnectionClosed.__init__W   sE     		,##t+d1B1WdiiSWFWXXXr&   c                $   U R                   c  U R                  c  gSU R                   S3$ U R                  c  SU R                    S3$ U R                  (       a  SU R                    SU R                   3$ SU R                   SU R                    3$ )Nzno close frame received or sentzsent z; no close frame receivedz	received z; no close frame sentz; then sent z; then received r-   r1   s    r'   __str__ConnectionClosed.__str__b   s    99yy 8tyyk)BCCyy "499+-BCC&&&tyykdii[II"499+-=dii[IIr&   c                    [         R                  " S[        5        U R                  c  [        R
                  R                  $ U R                  R                  $ )NzZConnectionClosed.code is deprecated; use Protocol.close_code or ConnectionClosed.rcvd.code)warningswarnDeprecationWarningr.   frames	CloseCodeABNORMAL_CLOSUREcoder5   s    r'   r?   ConnectionClosed.codes   sC    D	

 99##444yy~~r&   c                    [         R                  " S[        5        U R                  c  gU R                  R                  $ )Nz`ConnectionClosed.reason is deprecated; use Protocol.close_reason or ConnectionClosed.rcvd.reason )r9   r:   r;   r.   reasonr5   s    r'   rC   ConnectionClosed.reason~   s6    H	

 99yyr&   )r.   r0   r/   r,   )r.   frames.Close | Noner/   rE   r0   zbool | NonereturnNonerF   str)rF   int)r    r!   r"   r#   r$   r2   r6   propertyr?   rC   r%   r   r&   r'   r   r   H   sj    $ '+		Y!	Y "	Y $		Y
 
	YJ"      r&   r   c                      \ rS rSrSrSrg)r      z
Like :exc:`ConnectionClosed`, when the connection terminated properly.

A close code with code 1000 (OK) or 1001 (going away) or without a code was
received and sent.

r   Nr   r   r&   r'   r   r          r&   r   c                      \ rS rSrSrSrg)r	      z
Like :exc:`ConnectionClosed`, when the connection terminated with an error.

A close frame with a code other than 1000 (OK) or 1001 (going away) was
received or sent, or the closing handshake didn't complete properly.

r   Nr   r   r&   r'   r	   r	      rN   r&   r	   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r
      zD
Raised when connecting to a URI that isn't a valid WebSocket URI.

c                    Xl         X l        g r,   urimsg)r1   rU   rV   s      r'   r2   InvalidURI.__init__   s    r&   c                8    U R                    SU R                   3$ )Nz isn't a valid URI: rT   r5   s    r'   r6   InvalidURI.__str__   s    ((/z::r&   )rV   rU   N)rU   rI   rV   rI   rF   rG   rH   r    r!   r"   r#   r$   r2   r6   r%   r   r&   r'   r
   r
      s    
;r&   r
   c                      \ rS rSrSrSrg)r      zE
Base class for exceptions raised when the opening handshake fails.

r   Nr   r   r&   r'   r   r      r(   r&   r   c                      \ rS rSrSrSrg)r      z
Raised when a handshake request or response breaks a security rule.

Security limits can be configured with :doc:`environment variables
<../reference/variables>`.

r   Nr   r   r&   r'   r   r      rN   r&   r   c                      \ rS rSrSrSrg)r      z<
Raised when a handshake request or response is malformed.

r   Nr   r   r&   r'   r   r      r(   r&   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r      zB
Raised when a handshake response rejects the WebSocket upgrade.

c                    Xl         g r,   response)r1   re   s     r'   r2   InvalidStatus.__init__   s     r&   c                6    SU R                   R                  S 3$ )Nz+server rejected WebSocket connection: HTTP d)re   status_coder5   s    r'   r6   InvalidStatus.__str__   s    9$--:S:STU9VW	
r&   rd   N)re   zhttp11.ResponserF   rG   rH   rZ   r   r&   r'   r   r      s    
!
r&   r   c                  0    \ rS rSrSrSSS jjrS	S jrSrg)
r      zC
Raised when an HTTP header doesn't have a valid format or value.

Nc                    Xl         X l        g r,   namevaluer1   ro   rp   s      r'   r2   InvalidHeader.__init__       	
r&   c                    U R                   c  SU R                   S3$ U R                   S:X  a  SU R                   S3$ SU R                   SU R                    3$ )Nzmissing z headerrB   zempty zinvalid z	 header: rp   ro   r5   s    r'   r6   InvalidHeader.__str__   sY    ::dii[00ZZ2DII;g..dii[	$**>>r&   rn   r,   ro   rI   rp   
str | NonerF   rG   rH   rZ   r   r&   r'   r   r      s    
?r&   r   c                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r      zt
Raised when an HTTP header cannot be parsed.

The format of the header doesn't match the grammar for that header.

c                4   > [         TU ]  X SU SU 35        g )Nz at z in superr2   )r1   ro   errorheaderpos	__class__s        r'   r2   InvalidHeaderFormat.__init__   s!    SEfX>?r&   r   )
ro   rI   r~   rI   r   rI   r   rJ   rF   rG   r    r!   r"   r#   r$   r2   r%   __classcell__r   s   @r'   r   r      s    @ @r&   r   c                      \ rS rSrSrSrg)r      zu
Raised when an HTTP header has a wrong value.

The format of the header is correct but the value isn't acceptable.

r   Nr   r   r&   r'   r   r      s    r&   r   c                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r      z<
Raised when the Origin header in a request isn't allowed.

c                &   > [         TU ]  SU5        g )NOriginr|   )r1   originr   s     r'   r2   InvalidOrigin.__init__  s    6*r&   r   )r   rx   rF   rG   r   r   s   @r'   r   r      s    
+ +r&   r   c                      \ rS rSrSrSrg)r   i  z>
Raised when the Upgrade or Connection header isn't correct.

r   Nr   r   r&   r'   r   r     r(   r&   r   c                      \ rS rSrSrSrg)r   i  z?
Raised when negotiating an extension or a subprotocol fails.

r   Nr   r   r&   r'   r   r     r(   r&   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r   i  zC
Raised when a parameter name is repeated in an extension header.

c                    Xl         g r,   ro   r1   ro   s     r'   r2   DuplicateParameter.__init__      	r&   c                     SU R                    3$ )Nzduplicate parameter: r   r5   s    r'   r6   DuplicateParameter.__str__  s    &tyyk22r&   r   Nro   rI   rF   rG   rH   rZ   r   r&   r'   r   r     s    
3r&   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r   i   zB
Raised when a parameter name in an extension header is invalid.

c                    Xl         g r,   r   r   s     r'   r2   InvalidParameterName.__init__&  r   r&   c                     SU R                    3$ )Nzinvalid parameter name: r   r5   s    r'   r6   InvalidParameterName.__str__)  s    )$))55r&   r   Nr   rH   rZ   r   r&   r'   r   r      s    
6r&   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r   i-  zC
Raised when a parameter value in an extension header is invalid.

c                    Xl         X l        g r,   rn   rq   s      r'   r2   InvalidParameterValue.__init__3  rs   r&   c                    U R                   c  SU R                   3$ U R                   S:X  a  SU R                   3$ SU R                   SU R                    3$ )Nzmissing value for parameter rB   zempty value for parameter zinvalid value for parameter z: ru   r5   s    r'   r6   InvalidParameterValue.__str__7  sU    ::1$))==ZZ2/		{;;1$))BtzzlKKr&   rn   Nrw   rH   rZ   r   r&   r'   r   r   -  s    
Lr&   r   c                      \ rS rSrSrSrg)r   i@  z
Raised when receiving or sending a frame that breaks the protocol.

The Sans-I/O implementation raises this exception when:

* receiving or sending a frame that contains invalid data;
* receiving or sending an invalid sequence of frames.

r   Nr   r   r&   r'   r   r   @  s    r&   r   c                  L    \ rS rSrSr  S       S	S jjrS
S jrSS jrSrg)r   iL  a=  
Raised when parsing a frame with a payload that exceeds the maximum size.

The Sans-I/O layer uses this exception internally. It doesn't bubble up to
the I/O layer.

The :meth:`~websockets.extensions.Extension.decode` method of extensions
must raise :exc:`PayloadTooBig` if decoding a frame would exceed the limit.

Nc                    [        U[        5      (       a,  Ub   eUb   e[        R                  " S[        5        Xl        g S U l        Xl        Uc   eX l        S U l        U R                  U5        g )NzMPayloadTooBig(message) is deprecated; change to PayloadTooBig(size, max_size))

isinstancerI   r9   r:   r;   messagesizemax_sizecur_sizeset_current_size)r1   size_or_messager   r   s       r'   r2   PayloadTooBig.__init__X  sv     os++######MM:"
 (7LDL$3I'''!)M(,DM!!(+r&   c                    U R                   b  U R                   $ SnU R                  b  USU R                   S3-  nU R                  b  USU R                   S3-  nUSU R                   S3-  nU$ )Nzframe zwith z bytes zafter reading zexceeds limit of z bytes)r   r   r   r   )r1   r   s     r'   r6   PayloadTooBig.__str__o  sz    <<#<<Gyy$U499+W55}}(^DMM?'BB*4==/@@GNr&   c                `    U R                   b   eUb  U =R                  U-  sl        Xl         g g r,   )r   r   )r1   r   s     r'   r   PayloadTooBig.set_current_size{  s0    }}$$$MMX%M$M  r&   )r   r   r   r   )NN)r   zint | None | strr   
int | Noner   r   rF   rG   rH   )r   r   rF   rG   )	r    r!   r"   r#   r$   r2   r6   r   r%   r   r&   r'   r   r   L  sD    	  $#	,), , 	,
 
,.
%r&   r   c                      \ rS rSrSrSrg)r   i  a~  
Raised when sending a frame is forbidden in the current state.

Specifically, the Sans-I/O layer raises this exception when:

* sending a data frame to a connection in a state other
  :attr:`~websockets.protocol.State.OPEN`;
* sending a control frame to a connection in a state other than
  :attr:`~websockets.protocol.State.OPEN` or
  :attr:`~websockets.protocol.State.CLOSING`.

r   Nr   r   r&   r'   r   r     s    r&   r   c                      \ rS rSrSrSrg)r   i  z
Raised when receiving or sending messages concurrently.

WebSocket is a connection-oriented protocol. Reads must be serialized; so
must be writes. However, reading and writing concurrently is possible.

r   Nr   r   r&   r'   r   r     rN   r&   r   )r<   http11z.legacy.exceptions)AbortHandshakeInvalidStatusCodeRedirectHandshakeWebSocketProtocolError)deprecated_aliases)$r$   
__future__r   r9   importsr   __all__	Exceptionr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   AssertionErrorr   RuntimeErrorr   rB   r<   r   globalsr   r&   r'   <module>r      sf  > #   4 ? ) ? D) , ;# ;) $ % 
$ 
?$ ?&	@- 	@ +M +] ' 
3) 
3
6+ 
6L, L&	& 	3%& 3%l%~ )<   I /11"6	r&   