o
    àý°jz  ã                   @  s¦   d dl mZ d dlZd dlZd dlZd dlmZmZ d dlZd dl	m
Z
 d dlmZmZ d dlmZ ddd„Zddd„ZG dd„ dƒZddd„Zeejƒ e ¡  dS )é    )ÚannotationsN)ÚCallableÚMapping)ÚInternalError)Ú_opensslÚopenssl)ÚCONDITIONAL_NAMESÚokÚboolÚreturnÚNonec                 C  s"   | st  ¡ }td|›d�|ƒ‚d S )Nac  Unknown OpenSSL error. This error is commonly encountered when another library is not cleaning up the OpenSSL error stack. If you are using cryptography with another library that uses OpenSSL try disabling it before reporting a bug. Otherwise please file an issue at https://github.com/pyca/cryptography/issues with information on how to reproduce this. (ú))r   Úcapture_error_stackr   )r	   Úerrors© r   úŸ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/cryptography/hazmat/bindings/openssl/binding.pyÚ_openssl_assert   s   úøýr   Úlibú
typing.AnyÚconditional_namesú%Mapping[str, Callable[[], list[str]]]c                 C  sj   t  d¡}| |_tƒ }| ¡ D ]\}}t| |ƒs| |ƒ ¡ qt| ƒD ]}||vr2t||t| |ƒƒ q#|S )Nr   )	ÚtypesÚ
ModuleTypeÚ_original_libÚsetÚitemsÚgetattrÚupdateÚdirÚsetattr)r   r   Úconditional_libÚexcluded_namesÚ	conditionÚnames_cbÚattrr   r   r   Úbuild_conditional_library"   s   

€€r%   c                   @  s^   e Zd ZU dZdZded< ejZded< dZe	 
¡ Zdd
d„Zeddd„ƒZeddd„ƒZdS )ÚBindingz
    OpenSSL API wrapper.
    Nztyping.ClassVar[typing.Any]r   r   ÚffiFr   r   c                 C  ó   |   ¡  d S ©N©Ú_ensure_ffi_initialized)Úselfr   r   r   Ú__init__>   s   zBinding.__init__c                 C  sV   | j � | jsttjtƒ| _d| _W d   ƒ d S W d   ƒ d S 1 s$w   Y  d S )NT)Ú
_init_lockÚ_lib_loadedr%   r   r   r   ©Úclsr   r   r   r+   A   s   ÿû"ÿzBinding._ensure_ffi_initializedc                 C  r(   r)   r*   r0   r   r   r   Úinit_static_locksJ   s   zBinding.init_static_locks)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r'   r/   Ú	threadingÚLockr.   r-   Úclassmethodr+   r2   r   r   r   r   r&   4   s   
 
r&   ÚversionÚstrc                 C  sL   t j t jj¡}|  d¡|krtd| › d|› �ƒ‚tt j ¡ t	 
¡ kƒ d S )NÚasciizüThe version of cryptography does not match the loaded shared object. This can happen if you have multiple copies of cryptography installed in your Python path. Please try creating a new virtual environment to resolve this issue. Loaded python version: z, shared object version: )r   r'   Ústringr   ÚCRYPTOGRAPHY_PACKAGE_VERSIONÚencodeÚImportErrorr   ÚOpenSSL_version_numr   Úopenssl_version)r;   Úso_package_versionr   r   r   Ú_verify_package_versionO   s   ÿüûÿ	ÿrE   )r	   r
   r   r   )r   r   r   r   r   r   )r;   r<   r   r   )Ú
__future__r   r8   r   ÚtypingÚcollections.abcr   r   ÚcryptographyÚcryptography.exceptionsr   Ú"cryptography.hazmat.bindings._rustr   r   Ú1cryptography.hazmat.bindings.openssl._conditionalr   r   r%   r&   rE   Ú__version__r2   r   r   r   r   Ú<module>   s   



