o *g@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.Nwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cstjdtttd}|rtj}tj tj B}||}}n tj }tj }d|}}|tj O}|dr8|tj O}|dr@tj }nd}d} } z.t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| durt| | durt| )zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr)tempfilemktempformatosgetpidnext _mmap_counter_winapiPIPE_ACCESS_DUPLEX GENERIC_READ GENERIC_WRITEPIPE_ACCESS_INBOUNDFILE_FLAG_FIRST_PIPE_INSTANCEFILE_FLAG_OVERLAPPEDCreateNamedPipe PIPE_WAITNMPWAIT_WAIT_FOREVERNULL CreateFile OPEN_EXISTINGConnectNamedPipeGetOverlappedResult CloseHandle) rrr addressopenmodeaccessobsizeibsizeflags_and_attribsh1h2ovr-,/usr/lib/python3.10/asyncio/windows_utils.pyr sJ          rc@sbeZdZdZddZddZeddZdd Ze j d d d Z e j fd dZddZddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dSN_handleselfhandler-r-r.__init__Vs zPipeHandle.__init__cCs2|jdur d|j}nd}d|jjd|dS)Nzhandle=closed< >)r1 __class____name__r2r-r-r.__repr__Ys zPipeHandle.__repr__cCs|jSr/r0r3r-r-r.r4`szPipeHandle.handlecCs|jdur td|jS)NzI/O operation on closed pipe)r1 ValueErrorr=r-r-r.filenods zPipeHandle.fileno)r#cCs"|jdur||jd|_dSdSr/r0)r3r#r-r-r.closeis   zPipeHandle.closecCs.|jdur|d|t|d|dSdS)Nz unclosed )source)r1ResourceWarningr@)r3_warnr-r-r.__del__ns  zPipeHandle.__del__cCs|Sr/r-r=r-r-r. __enter__sszPipeHandle.__enter__cCs |dSr/)r@)r3tvtbr-r-r.__exit__vs zPipeHandle.__exit__N)r; __module__ __qualname____doc__r5r<propertyr4r?rr#r@warningswarnrDrErIr-r-r-r.rQs  rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|drJ|dddksJd}}}d} } } |tkr1tddd\} } t| tj}n|}|tkrEtdd\} } t| d}n|}|tkrYtdd\} }t|d}n |tkr`|}n|}zaztj |f|||d |Wn| | | fD] }|durt |q|| durt | |_ | durt | |_| durt | |_W|tkrt||tkrt||tkrt|dSdS|tkrt||tkrt||tkrt|ww) Nuniversal_newlinesr r)FTT)rr)TFr )stdinstdoutstderr)getrrmsvcrtopen_osfhandlerO_RDONLYSTDOUTsuperr5rr#rrQrRrSr@)r3argsrQrRrSkwds stdin_rfd stdout_wfd stderr_wfdstdin_wh stdout_rh stderr_rhstdin_rh stdout_wh stderr_whhr:r-r.r5sf            zPopen.__init__)NNN)r;rJrKrLr5 __classcell__r-r-rfr.r}sr)rLsysplatform ImportErrorr itertoolsrUr subprocessr rN__all__BUFSIZErrXcountrrrrr-r-r-r.s& 1,