a ‚oeÓ ã@sðddlZddlZddlZddlmZmZmZmZmZddl m Z ee e ej fZe ƒZejZejZejdd�Zee dœdd„Zeeed œd d „Zeeeegefd œd d„Zee dœdd„Ze e dœdd„ZeƒZdZe eedœdd„ZdS)éN)ÚAnyÚCallableÚNoReturnÚTypeÚUnion)ÚBindingF)Zshould_clear_after_alloc)ÚcharpÚreturncCs|sdSt |¡ d¡S)zª Get a native string type representing of the given CFFI ``char*`` object. :param charp: A C-style string represented using CFFI. :return: :class:`str` Úúutf-8)ÚffiÚstringÚdecode)r©rú.C:\Program Files\Certbot\pkgs\OpenSSL\_util.pyÚtextsr)Úexception_typer cCsRg}t ¡}|dkrqF| tt |¡ƒtt |¡ƒtt |¡ƒf¡q||ƒ‚dS)ac Convert an OpenSSL library failure into a Python exception. When a call to the native OpenSSL library fails, this is usually signalled by the return value, and an error code is stored in an error queue associated with the current thread. The err library provides functions to obtain these error codes and textual error messages. rN)ÚlibZ ERR_get_errorÚappendrZERR_lib_error_stringZERR_func_error_stringZERR_reason_error_string)rÚerrorsÚerrorrrrÚexception_from_error_queue"s    ýÿr)rr cstddœ‡fdd„ }|S)z~ Create an assert function that uses :func:`exception_from_error_queue` to raise an exception wrapped by *error*. N)Úokr cs|durtˆƒdS)zT If *ok* is not True, retrieve the error from OpenSSL and raise it. TN)r)r©rrrÚopenssl_assertBsz#make_assert..openssl_assert)Úbool)rrrrrÚ make_assert<sr)Úsr cCs*t |¡}t|tƒr"| t ¡¡S|SdS)zâ Convert a Python path to a :py:class:`bytes` for the path which can be passed into an OpenSSL API accepting a filename. :param s: A path (valid for os.fspath). :return: An instance of :py:class:`bytes`. N)ÚosÚfspathÚ isinstanceÚstrÚencodeÚsysÚgetfilesystemencoding)rÚbrrrÚ path_bytesLs  r&cCs | d¡S)NÚcharmap)r")rrrrÚ byte_string]sr(z,str for {0} is no longer accepted, use bytes)ÚlabelÚobjr cCs.t|tƒr*tjt |¡tdd�| d¡S|S)aØ If ``obj`` is text, emit a warning that it should be bytes instead and try to convert it to bytes automatically. :param str label: The name of the parameter from which ``obj`` was taken (so a developer can easily find the source of the problem and correct it). :return: If ``obj`` is the text string type, a ``bytes`` object giving the UTF-8 encoding of that text is returned. Otherwise, ``obj`` itself is returned. é)ÚcategoryÚ stacklevelr )r r!ÚwarningsÚwarnÚ _TEXT_WARNINGÚformatÚDeprecationWarningr")r)r*rrrÚtext_to_bytes_and_warnhs ý r3)rr#r.ÚtypingrrrrrZ,cryptography.hazmat.bindings.openssl.bindingrr!ÚbytesÚPathLikeZStrOrBytesPathZbindingr rZ new_allocatorZno_zero_allocatorrÚ Exceptionrrrr&r(ÚobjectZ UNSPECIFIEDr0r3rrrrÚs"