a c@sddlmZmZmZmZmZmZmZmZgdZ Gddde Z Gddde Z Gddde Z deeeeeeeefd d d Zed ddZGdddeZeeeeeefedddZdS))AnyDictNoReturnPatternTupleTypeTypeVarUnion) ProtocolErrorLocalProtocolErrorRemoteProtocolErrorvalidatebytesifyc@s$eZdZdZdeeddddZdS)r aMException 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. N)msgerror_status_hintreturncCs*t|turtdt||||_dS)Nz+tried to directly instantiate ProtocolError)typer TypeError Exception__init__r)selfrrrV/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/h11/_util.pyr)s  zProtocolError.__init__)r)__name__ __module__ __qualname____doc__strintrrrrrr sr c@seZdZedddZdS)r rcCst|_|dSN)r __class__rrrr!_reraise_as_remote_protocol_error<s z4LocalProtocolError._reraise_as_remote_protocol_errorN)rrrrr$rrrrr ;sr c@s eZdZdS)r N)rrrrrrrr Psr malformed data)regexdatar format_argsrcGs,||}|s$|r|j|}t||Sr!) fullmatchformatr groupdict)r&r'rr(matchrrrr Ts   r _T_SentinelSentinel)boundcsNeZdZeeeeedfeee fe edfdd Z edddZ Z S)r..)clsnamebases namespacekwdsrc s2|tfksJtj||||fi|}||_|Sr!)r.super__new__r")r0r1r2r3r4vr"rrr6lszSentinel.__new__r cCs|jSr!)rr#rrr__repr__xszSentinel.__repr__) rrrrr-rrrrrr6r9 __classcell__rrr8rr.ks   )srcCs>t|tur|St|tr$|d}t|tr6tdt|S)Nasciiz#expected bytes-like object, not int)rbytes isinstancerencoderr)r;rrrrs    rN)r%)typingrrrrrrrr __all__rr r r r=rr r-rr. bytearray memoryviewrrrrrrs( /