B aA @s(ddlZddlZddlZddlZddlmZmZmZmZmZm Z m Z m Z m Z ddl mZmZmZmZmZmZmZmZddlZdZeZe ZeZeeZGdddeZeeZGdddeZeeZ Gd d d ejZ!e j"j#Z#eeeeeeeeee g e#_$ee#_%d d Z&Gd ddej'Z'e&e_&dS)N) StructureWinErrorbyrefc_char_pc_void_pc_wchar c_wchar_psizeofwindll)BOOLBYTEDWORDHANDLELPCWSTRLPVOIDLPWSTRWORDic@s|eZdZdefdefdefdefdefdefdefdefd efd efd efd efd efdefdefdefdefdefgZdS) STARTUPINFOWcbZ lpReservedZ lpDesktopZlpTitleZdwXZdwYZdwXSizeZdwYSizeZ dwXCountCharsZ dwYCountCharsZdwFillAtrributedwFlags wShowWindowZ cbReserved2Z lpReserved2 hStdInput hStdOutput hStdErrorN) __name__ __module__ __qualname__r rrLPBYTEr_fields_rr[/opt/alt/python37/lib/python3.7/site-packages/virtualenv/util/subprocess/_win_subprocess.pyrs        rc@s(eZdZdefdefdefdefgZdS)PROCESS_INFORMATIONhProcesshThread dwProcessId dwThreadIdN)rrrrr rrrrr r!(s r!cs,eZdZfddZddZddZZS) DUMMY_HANDLEcstt|j||d|_dS)NF)superr&__init__closed)selfakw) __class__rr r(3szDUMMY_HANDLE.__init__cCs|jstj|d|_dS)NT)r)r kernel32Z CloseHandle)r*rrr Close7s zDUMMY_HANDLE.ClosecCs|jS)N)value)r*rrr __int__<szDUMMY_HANDLE.__int__)rrrr(r/r1 __classcell__rr)r-r r&1s r&c Cst|j|jtt|jdkr |jnt|j|jdkr8|jnt|j|jdkrP|jnt|jd} d} |dk rtd dd| Dtd}t t |} || _ d} |dk rt|} t} |tO}t||dd||| | t| t|  rt| jt| j| j| jfStdS)zCreate a process supporting unicode executable and args for win32 Python implementation of CreateProcess using CreateProcessW for Win32 N)rrrrrrcSs g|]\}}td||fqS)z%s=%s)unicode).0kvrrr gsz!CreateProcess..)rrrr rintrrr4joinitemsrlenr0r!CREATE_UNICODE_ENVIRONMENTCreateProcessWrr&r"r#r$r%r) executableargsZ_p_attrZ_t_attrZinherit_handlesZcreation_flagsenvcwdZ startup_infosiZwenvZwcwdpirrr CreateProcessMs6    rFcs eZdZdZfddZZS)Popenz>This superseeds Popen and corrects a bug in cPython 2.7 implemcs|dkrt}t|tjjsLdd|D}t|}tdkrL|d}|j t j O_ t j |_ |dkrrtjn|}|dtd}t dkstj|d kr|}td ||f}| t jO} tt|||||||||| d | | | ||||dS) aCode from part of _execute_child from Python 2.7 (9fbb65e) There are only 2 little changes concerning the construction of the the final string in shell mode: we preempt the creation of the command string when shell is True, because original function will try to encode unicode args which we want to avoid to be able to sending it as-is to ``CreateProcess``. NcSs$g|]}t|tr|n|dqS)zutf-8) isinstancebytesencode)r5irrr r8sz(Popen._execute_child..CPythonzutf-8ZCOMSPECzcmd.exelz command.comz"%s" %sF) subprocessZ STARTUPINFOrHtypesZ StringTypes list2cmdlineplatformpython_implementationdecoder _subprocessZSTARTF_USESHOWWINDOWZSW_HIDErosenvirongetr4Z GetVersionpathbasenamelowerZ_find_w9xpopenZCREATE_NEW_CONSOLEr'rG_execute_child)r*rAr@ preexec_fn close_fdsrCrBuniversal_newlines startupinfo creationflagsshellto_closep2creadp2cwritec2preadc2pwriteerrreaderrwriteZcomspecZw9xpopen)r-rr rZs*        zPopen._execute_child)rrr__doc__rZr2rr)r-r rGsrG)(ctypesrTrPrMrrrrrrrr r Zctypes.wintypesr r r rrrrrrSr>ZLPCTSTRZLPTSTRZLPSECURITY_ATTRIBUTESPOINTERrrZLPSTARTUPINFOWr!ZLPPROCESS_INFORMATIONr&r.r?argtypesrestyperFrGrrrr s0,(     4.