a DOg3@sddlZddlZddlZddlZddlZddlZddlmZm Z ddgZ Gddde Z Gddde Z dd d Zd d d Zefd dZGdddeZd!ddZd"ddZefddZddZd#ddZedkr eejdkredejdnejd=eejddS)$N) read_code get_importer run_modulerun_pathc@s$eZdZddZddZddZdS) _TempModulecCs||_t||_g|_dSN)mod_nametypes ModuleTypemodule _saved_moduleselfrr/usr/lib64/python3.9/runpy.py__init__s z_TempModule.__init__cCs@|j}z|jtj|Wnty.Yn0|jtj|<|Sr)rr appendsysmodulesKeyErrorr r rrr __enter__ s  z_TempModule.__enter__cGs.|jr|jdtj|j<n tj|j=g|_dSNr)r rrrrargsrrr__exit__)s z_TempModule.__exit__N__name__ __module__ __qualname__rrrrrrrrs rc@s$eZdZddZddZddZdS)_ModifiedArgv0cCs||_t|_|_dSr)valueobject _saved_value _sentinel)rr rrrr1sz_ModifiedArgv0.__init__cCs0|j|jurtdtjd|_|jtjd<dS)NzAlready preserving saved valuer)r"r# RuntimeErrorrargvr )rrrrr5s  z_ModifiedArgv0.__enter__cGs|j|_|jtjd<dSr)r#r r"rr%rrrrr;sz_ModifiedArgv0.__exit__Nrrrrrr0src Csn|dur|||dur(d}|}d} n |j}|j}|j} |durH|j}|j||| d|||dt|||S)N)r__file__ __cached____doc__ __loader__ __package____spec__)updateloaderorigincachedparentexec) code run_globals init_globalsrmod_specpkg_name script_namer-fnamer/rrr _run_code@s*  r9c Cs|dur |n|j}t|T}t|,|jj}t|||||||Wdn1sV0YWdn1st0Y|Sr)r.rrr __dict__r9copy) r2r4rr5r6r7r8 temp_module mod_globalsrrr_run_module_codeZs@r>c Csd|dr|d|d\}}}|rz t|WnJty|}z2|jdusf|j|krh||jdshWYd}~n d}~00tj|}|durt|dsddl m }dj ||d}|t |zt j|}WnvttttfyH} zTd}|d r|d |dd d |d 7}|| |t| j| | WYd} ~ n d} ~ 00|dur`|d||jdur|dks|dr|dz|d} t| |WS|y}z*|tjvr|d||fWYd}~n d}~00|j} | dur|d|z| |} Wn4tyB}z|t ||WYd}~n d}~00| durZ|d|||| fS)N.z#Relative module names not supported__path__r)warnz{mod_name!r} found in sys.modules after import of package {pkg_name!r}, but prior to execution of {mod_name!r}; this may result in unpredictable behaviour)rr6z:Error while finding module specification for {!r} ({}: {})z.pyz . Try using 'z' instead of 'z' as the module name.zNo module named %s__main__z .__main__z%Cannot use package as __main__ modulez3%s; %r is a package and cannot be directly executedz0%r is a namespace package and cannot be executedzNo code object available for %s) startswith rpartition __import__ ImportErrornamerrgethasattrwarningsrAformatRuntimeWarning importlibutil find_specAttributeError TypeError ValueErrorendswithtypersubmodule_search_locations_get_module_detailsr-get_code) rerrorr6_eexistingrAmsgspecex pkg_main_namer-r2rrrrWhsj       0      $  rWc@s eZdZdS)_ErrorN)rrrrrrrrasraTc Csz0|s|dkr t|t\}}}ntt\}}}Wn<tyl}z$dtj|f}t|WYd}~n d}~00tjdj}|r|jtj d<t ||dd|S)NrCz%s: %sr) rWra_get_main_module_detailsr executableexitrr:r.r%r9)r alter_argvr5r2excr] main_globalsrrr_run_module_as_mains    rhFcCs@t|\}}}|dur|}|r,t||||St|i|||SdSr)rWr>r9)rr4run_name alter_sysr5r2rrrrs c Csd}tj|}tj|=zpzt|WW|tj|<Styx}z2|t|vrb|d|tjdf|WYd}~n d}~00W|tj|<n |tj|<0dS)NrCzcan't find %r module in %rr)rrrWrGstrpath)rY main_name saved_mainrfrrrrbs      rbcCstjt|}t|}t|}Wdn1s:0Y|durt| }t||d}Wdn1s|0Y||fS)Nr1) osrlabspathfsdecodeio open_codercompileread)rir8 decoded_pathfr2rrr_get_code_from_files & .rxc Cs|dur d}|dd}t|}d}t|jdkrFt|jdkrFd}t|tdsX|rxt||\}}t|||||dStj d|zt \}} }t |} t |d| jj} t|| ||| |WdWdWztj |WStyYS0S1s0YWdn1s20YWztj |WntybYn0n(ztj |WntyYn00dS) Nz r?rFimp NullImporterT)r6r7)rErrUrr isinstancerxr>rrlinsertrbrrr r:r9r;removerS) path_namer4rir6importeris_NullImporterr2r8rr5r<r=rrrrsH  $6rCz!No module specified for execution)file)NNNNN)NNNNN)T)NNF)NN)rimportlib.machineryrNimportlib.utilrrr ropkgutilrr__all__r!rrr9r>rGrW Exceptionrarhrrbrxrrlenr%printstderrrrrr s@   =    6