u\wXdZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z ddl m Z mZddlmZmZmZmZddlmZddlmZmZmZmZdd lmZmZdd lmZdd l m!Z!eeZej"j#Z$Gd d Z%ddZ&GddZ'ddZ(ddZ)d dZ*d dZ+dS)!zExecute files of Python code.) annotationsN) ModuleSpec)CodeType ModuleType)AnyListOptionalTuple)env)CoverageException_ExceptionDuringRunNoCodeNoSource)canonical_filenamepython_reported_file)isolate_module)get_python_sourceceZdZdZd dZd S) DummyLoaderzzA shim for the pep302 __loader__, emulating pkgutil.ImpLoader. Currently only implements the .fullname attribute fullnamestr_argsrreturnNonec||_dS)N)r)selfrrs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/execfile.py__init__zDummyLoader.__init__$s   N)rrrrrr)__name__ __module__ __qualname____doc__rrrrrs2!!!!!!rr modulenamerr%Tuple[Optional[str], str, ModuleSpec]c tj|}n/#t$r"}t t ||d}~wwxYw|st d||j}|j}|jrM|dz}tj|}|st d|d|dz|j}|j}| dd}|||fS)zFind the module named `modulename`. Returns the file path of the module, the name of the enclosing package, and the spec. NzNo module named z .__main__z; z- is a package and cannot be directly executed.r) importlibutil find_spec ImportErrorrroriginnamesubmodule_search_locations rpartition)r%specerrpathname packagenamemod_mains r find_moduler6(s*~'' 33 ***s3xx  c)* :8*88999{H)K &   +~''11 /8///NNNO ;i ((--a0K [$ &&s" AA  Ac4eZdZdZddd Zdd Zdd Zdd Zd S)PyRunnerzwMulti-stage execution of Python code. This is meant to emulate real Python execution as closely as possible. Fargs List[str] as_moduleboolrrc||_||_|d|_d|_d|_d|_d|_d|_dS)Nr)r9r;arg0packager%r3loaderr1)rr9r;s rrzPyRunner.__init__LsB "G &* )-'+ -1 *. rc|jrtj}nmtj|jr|j}nAtjtj|j}tjtjdrtj ddj j }tjtjd}tjtj|}t|}t|}||krd}nPtjdtjtjdkr tjd=|t|tjd<dSdS)zsSet sys.path properly. This needs to happen before any importing, and without importing anything. rN)r;osgetcwdpathisdirr>abspathdirnamesysinspectstackf_code co_filenamerr)rpath0top_filesys_path_0_abstop_file_dir_abss rpreparezPyRunner.prepareWsZ > @IKKEE W]]49 % % @IEEGOOBGOODI$>$>??E 7==! % % }r*1-4@HW__SXa[99N!wrwx/H/HII /??N12BCC !111 x{bgoochqk::::HQK  .u55CHQKKK  rc|jr|j|_t|j\}|_|_|j|jj|_t|j|_|Jtj ||_ |j x|j d<|_n2tj |jrdD]}tj |jd|z}t jdkrtj |}tj |r ||_nt'd|jdt)|}t*jdd||_d |j_d |_td|_ntd|_t)|j|_dS) zDo more preparation to run Python code. Includes finding the module to run and adjusting sys.argv[0]. This method is allowed to import code. Nr)z.py.pyc.pyo__main__) z!Can't find '__main__' module in '')r-T)r;r>r%r6r?r1r.rr@rDrFrHr3r9rGjoinr PYVERSIONexistsrrr) machineryr has_location)rr3ext try_filenames r _prepare2zPyRunner._prepare2~s > 2"iDO0;DO0L0L -HdlDIy$"&).%do66DK'''GOOH55DM'+} 4DIaL499 W]]49 % % 2/ Q Q!w||DIzC7GHH =J..#%7??<#@#@L7>>,// ,DIEO49OOOPPP0 ==L!+66z4P\6]]DI%)DI "DL%j11DKK%j11DK(33 rc|td}|jd}|j|_|r|jdd|_|j |j|_|j|_|j |j |_ tj d|_ |tj d<|jt_ |rt!|j}nt#|j}nF#t$$rt&$r/}d|jd|jjd|}t%||d}~wwxYwt-j} t1||jnj#t4$rt&$rRtj\}}} |J|J| Jt9|d d |jJ|jj|_tj||| jtj d n#t4$rt&$r}tj!"d tj\} } } | J| J| Jd | _#| jJ| jj| _tj$| | | jtj!"d tK||| j|d}~wwxYwYnwxYwt-j&|dS#t-j&|wxYw)zRun the Python code!rW)rUrVNrBbuiltinszCouldn't run 'z' as Python code: z: __context__rCzError in sys.excepthook: Tz Original exception was: )'rdrr>endswith__file__r? __package__r@ __loader__r1__spec__rJmodules __builtins__r9argvmake_code_from_pycmake_code_from_pyr Exception __class__r rDrEexec__dict__ SystemExitexc_infogetattr __traceback__tb_next excepthookexitstderrwrite__suppress_context____excepthook__r chdir) rmain_modfrom_pyccodeexcmsgcwdtypr2tbtyp2err2tb2s rrunz PyRunner.runsK j))9%%&677 I  7 ( 1#2# 6H  < ##'>LCb??????>>> C - - - (444$'$5$=!sC444$ #    I I I   !=>>>"%,..dC'''''',0))555%)%7%?""4s{;;;   !>???)#sBJ??SH I O' R HSMMMMMBHSMMMMsh +C66D9 *D44D9E'%K''A K15G;&K;KB4KKK K' KK''K=N)F)r9r:r;r<rr)rr)r r!r"r#rrSrdrr$rrr8r8Fs{ / / / / /%6%6%6%6N)4)4)4)4VXXXXXXrr8r9r:rcxt|d}||dS)aRun a Python module, as though with ``python -m name args...``. `args` is the argument array to present as sys.argv, including the first element naming the module being executed. This is a helper for tests, to encapsulate how to use PyRunner. Tr;Nr8rSrr9runners rrun_python_modulers7dd + + +F NN JJLLLLLrcxt|d}||dS)aGRun a Python file as if it were the main program on the command line. `args` is the argument array to present as sys.argv, including the first element naming the file being executed. `package` is the name of the enclosing package, if any. This is a helper for tests, to encapsulate how to use PyRunner. FrNrrs rrun_python_filers7de , , ,F NN JJLLLLLrfilenamerc t|}n-#ttf$r}td|d|d}~wwxYwt||ddS)z8Get source from `filename` and make a code object of it.No file to run: 'r[NrtT) dont_inherit)rOSErrorrcompile)rsourcers rrqrq!stA"8,, X AAA6866677S@A 68V$ ? ? ??s<7<c` t|d}n&#t$r}td|d|d}~wwxYw|5|d}|tkrtd|dtt jd|dd }|d z}|r|d n*|d|dtj|}t|tsJ dddn #1swxYwY|S) z#Get a code object from a .pyc file.rbrr[NzBad magic number in .pyc file: z != z? ** !  $ $ $\5\\HX\\]] ] dDIIaLL11!4T\   IIaLLLL IIaLLL IIaLLL|D!!$))))))%***************( Ks" 616CD##D'*D')r%rrr&)r9r:rr)rrrr),r# __future__rimportlib.machineryr)importlib.utilrKrrDrrJrtypesrrtypingrrr r coverager coverage.exceptionsr r rrcoverage.filesrr coverage.miscrcoverage.pythonrr* MAGIC_NUMBERrrr6r8rrrqrpr$rrrs $#"""""" ******&&&&&&&&------------XXXXXXXXXXXXCCCCCCCC((((((------^B>.!!!!!!!!''''<{{{{{{{{|        @@@@r