a �DOg3�@sddlZddlZddlZddlZddlZddlZddlmZm Z ddgZ Gdd�de �Z Gdd�de �Z dd d �Zd d d �Zefd d�ZGdd�de�Zd!dd�Zd"dd�Zefdd�Zdd�Zd#dd�Zedk�r eej�dk�r�edejd�nejd=eejd�dS)$�N)� read_code� get_importer� run_module�run_pathc@s$eZdZdd�Zdd�Zdd�ZdS)� _TempModulecCs||_t�|�|_g|_dS�N)�mod_name�types� ModuleType�module� _saved_module��selfr�r�/usr/lib64/python3.9/runpy.py�__init__s z_TempModule.__init__cCs@|j}z|j�tj|�Wnty.Yn0|jtj|<|Sr)rr �append�sys�modules�KeyErrorr r rrr� __enter__ s  z_TempModule.__enter__cGs.|jr|jdtj|j<n tj|j=g|_dS�Nr)r rrr�r�argsrrr�__exit__)s z_TempModule.__exit__N��__name__� __module__� __qualname__rrrrrrrrs rc@s$eZdZdd�Zdd�Zdd�ZdS)�_ModifiedArgv0cCs||_t�|_|_dSr)�value�object� _saved_value� _sentinel)rr rrrr1sz_ModifiedArgv0.__init__cCs0|j|jurtd��tjd|_|jtjd<dS)NzAlready preserving saved valuer)r"r#� RuntimeErrorr�argvr )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|||d�t||�|S)N)r�__file__� __cached__�__doc__� __loader__� __package__�__spec__)�update�loader�origin�cached�parent�exec) �code� run_globals� init_globalsr�mod_spec�pkg_name� script_namer-�fnamer/rrr� _run_code@s* � r9c Cs�|dur |n|j}t|��T}t|��,|jj}t|||||||�Wd�n1sV0YWd�n1st0Y|��Sr)r.rrr �__dict__r9�copy) r2r4rr5r6r7r8� temp_module� mod_globalsrrr�_run_module_codeZs�@r>c Csd|�d�r|d��|�d�\}}}|r�z t|�WnJty|}z2|jdusf|j|krh|�|jd�sh�WYd}~n d}~00tj�|�}|dur�t|d�s�ddl m }dj ||d�}|t |��zt j�|�}Wnvttttf�yH} zTd}|�d ��r|d |dd ��d |�d �7}||� |t| �j| ��| �WYd} ~ n d} ~ 00|du�r`|d|��|jdu�r�|dk�s�|�d��r�|d��z|d} t| |�WS|�y�}z*|tjv�r��|d||f��WYd}~n d}~00|j} | du�r|d|��z| �|�} Wn4t�yB}z|t |��|�WYd}~n d}~00| du�rZ|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__� ImportError�namerr�get�hasattr�warningsrA�format�RuntimeWarning� importlib�util� find_spec�AttributeError� TypeError� ValueError�endswith�typer�submodule_search_locations�_get_module_detailsr-�get_code) r�errorr6�_�e�existingrA�msg�spec�ex� pkg_main_namer-r2rrrrWhsj  �  �  � 0     � �$  rWc@s eZdZdS)�_ErrorN)rrrrrrrra�sraTc Cs�z0|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� executable�exitrr:r.r%r9)r� alter_argvr5r2�excr]� main_globalsrrr�_run_module_as_main�s    �rhFcCs@t|�\}}}|dur|}|r,t||||�St|i|||�SdSr)rWr>r9)rr4�run_name� alter_sysr5r2rrrr�s c Cs�d}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)rrrWrG�str�path)rY� main_name� saved_mainrfrrrrb�s    �  ��rbcCs�tj�t�|��}t�|��}t|�}Wd�n1s:0Y|dur�t�|�� }t|��|d�}Wd�n1s|0Y||fS)Nr1) �osrl�abspath�fsdecode�io� open_coder�compile�read)rir8� decoded_path�fr2rrr�_get_code_from_file�s & .rxc Cs�|dur d}|�d�d}t|�}d}t|�jdkrFt|�jdkrFd}t|td��sX|rxt||�\}}t|||||d�Stj � d|�z�t �\}} }t |���} t |��d| jj} t|| ||| |���Wd�Wd�Wztj �|�WSt�yYS0S1�s0YWd�n1�s20YWztj �|�Wnt�ybYn0n(ztj �|�Wnt�y�Yn00dS) Nz r?rF�imp� NullImporterT)r6r7)rErrUrr� isinstancerxr>rrl�insertrbrrr r:r9r;�removerS) � path_namer4rir6�importer�is_NullImporterr2r8rr5r<r=rrrrsH�  ��$�6�rC�z!No module specified for execution)�file)NNNNN)NNNNN)T)NNF)NN)r�importlib.machineryrN�importlib.utilrrr ro�pkgutilrr�__all__r!rrr9r>rGrW� Exceptionrarhrrbrxrr�lenr%�print�stderrrrrr� s@�� �  = �   6