U e5d��@s�dZddlZejdkred��ddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZe��Zdde d �d d �ZGd d �d �ZGdd�dej�ZdS)z)Various Windows specific bits and pieces.�NZwin32z win32 only)�pipe�Popen�PIPE� PipeHandlei F)TT)�duplex� overlapped�bufsizec Cs$tjd�t��tt��d�}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|dr�tj }nd}d} } z\t�||tjd||tjtj�} t�||dtjtj|tj�} tj| dd�} | �d�| | fWS| dk �rt�| �| dk �rt�| ��YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�NT�r)�tempfileZmktemp�format�os�getpid�next� _mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult� CloseHandle) rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2Zov�r�-/usr/lib64/python3.8/asyncio/windows_utils.pyr sb��     ��      rc@sbeZdZdZdd�Zdd�Zedd��Zdd �Ze j d �d d �Z e j fd d�Zdd�Zdd�ZdS)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS�N��_handle��self�handlerrr�__init__VszPipeHandle.__init__cCs2|jdk rd|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r� __class__�__name__rrrr�__repr__Ys zPipeHandle.__repr__cCs|jSrr�rrrrr`szPipeHandle.handlecCs|jdkrtd��|jS)NzI/O operation on closed pipe)r� ValueErrorr%rrr�filenods zPipeHandle.fileno)rcCs|jdk r||j�d|_dSrr)rrrrr�closeis  zPipeHandle.closecCs*|jdk r&|d|��t|d�|��dS)Nz unclosed )�source)r�ResourceWarningr()rZ_warnrrr�__del__ns zPipeHandle.__del__cCs|Srrr%rrr� __enter__sszPipeHandle.__enter__cCs |��dSr)r()r�t�v�tbrrr�__exit__vszPipeHandle.__exit__N)r#� __module__� __qualname__�__doc__rr$�propertyrr'rrr(�warnings�warnr+r,r0rrrrrQs rcs"eZdZdZd�fdd� Z�ZS)rz�Replacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s�|�d�rt�|�dd�dks"t�d}}}d} } } |tkrbtddd�\} } t�| tj�}n|}|tkr�tdd�\} } t�| d�}n|}|tkr�tdd�\} }t�|d�}n|tkr�|}n|}z�z t �j |f|||d �|��Wn0| | | fD]}|dk r�t � |�q��Yn>X| dk �r,t| �|_| dk �r@t| �|_| dk �rTt| �|_W5|tk�rlt� |�|tk�r�t� |�|tk�r�t� |�XdS) NZuniversal_newlinesrr)FTT)rr)TFr )�stdin�stdout�stderr)�get�AssertionErrorrr�msvcrtZopen_osfhandler�O_RDONLY�STDOUTr(�superrrrrr7r8r9)r�argsr7r8r9�kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_wh�h�r"rrr�sR  ��            zPopen.__init__)NNN)r#r1r2r3r� __classcell__rrrCrr}sr)r3�sys�platform� ImportErrorr� itertoolsr<r� subprocessr r5�__all__ZBUFSIZErr>�countrrrrrrrr�s$ 1,