
    
d1                     `    d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d Z	 G d de
          ZdS )    N)get_ipython)PY2c                     t           j                            |           } t          j        |d          }| |_        d |_        |S )zt
    Reimplemented from IPython/core/interactiveshell.py to avoid caching
    and clearing recursive namespace.
    z(Module created for script run in IPython)docc                      dS )NT r       Jlib/python3.11/site-packages/spyder_kernels/customize/namespace_manager.py<lambda>znew_main_mod.<locals>.<lambda>   s    D r	   )ospathabspathtypes
ModuleType__file____nonzero__)filenamemodnamemain_mods      r
   new_main_modr      sO    
 wx((H68 8 8H !H )=HOr	   c                   *    e Zd ZdZ	 	 ddZd Zd ZdS )	NamespaceManagerz
    Get a namespace and set __file__ to filename for this namespace.

    The namespace is either namespace, the current namespace if
    current_namespace is True, or a new namespace.
    NF   c                    || _         || _        d | _        || _        d | _        d | _        d | _        d| _        || _        t                      }|
                    |dz             | _        |                    |dz             | _        d S )NFr   )r   
ns_globals	ns_localscurrent_namespace_previous_filename_previous_main_previous_running_namespace_reset_main
_file_coder   get_global_scopecontext_globalsget_local_scopecontext_locals)selfr   	namespacer   	file_codestack_depthipython_shells          r
   __init__zNamespaceManager.__init__,   s     #!2"&"+/( ##,==kAoNN+;;K!OLLr	   c                 `   t                      }| j        | j        rC| j        | _        | j        | _        d| j        v r| j        d         | _        | j        | j        d<   nct          | j        d          }|j	        | _        d| _        dt          j        v rt          j        d         | _        |t          j        d<   d| _        |j        j        | _        | j        | j        f|j        _        | j        Xt$          sQt'          | j        t(                    r7	 | j                                        | _        n# t,          $ r
 d| _        Y nw xY w| j        Pt/          | j                  dd | j                                        D             | j        ft2          j        | j        <   | j        | j        fS )z(
        Prepare the namespace.
        Nr   __main__Tc                     g | ]}|d z   S )
r   ).0lines     r
   
<listcomp>z.NamespaceManager.__enter__.<locals>.<listcomp>e   s    FFFFFFr	   )r   r   r   r$   r&   r   r   r   r   __dict__sysmodulesr   r!   kernel_running_namespacer    r"   r   
isinstancebytesdecodeUnicodeDecodeErrorlen
splitlines	linecachecache)r'   r+   r   s      r
   	__enter__zNamespaceManager.__enter__;   s   
 $?"% ("&"6!%!400.2oj.ID+.2m
++'zBB"*"3!%,,*-+j*AD'*2J'#'   3 	( OT^3-/ O' (t66 ('"&/"8"8":":% ' ' '"&' ?& DO$$dFF)C)C)E)EFFF.IODM* ..s   D4 4EEc                    t                      }| j        |j        _        | j        r| j        | j        d<   n#d| j        v r| j                            d           | j        sL| j        	                    | j                   | j
        r&| j        r| j
        	                    | j                   | j        r| j        t          j        d<   n"dt          j        v r| j        rt          j        d= | j        t"          j        v rJt&          j                            | j                  r(t"          j                            | j                   dS dS dS )z&
        Reset the namespace.
        r   r.   N)r   r    r7   r8   r   r   popr   r$   updater&   r   r   r5   r6   r!   r   r?   r@   r   r   exists)r'   exc_typeexc_valexc_tbr+   s        r
   __exit__zNamespaceManager.__exit__i   s;    $, 	/" 	,*.*ADOJ''4?**O
+++% 	; ''888" ;t~ ;#**4>::: 	(&*&9CK
##3;&&4+;&J'=IO++t}0M0M+O..... ,+++r	   )NFNr   )__name__
__module____qualname____doc__r,   rA   rI   r   r	   r
   r   r   $   s_          DI-.M M M M,/ ,/ ,/\/ / / / /r	   r   )r?   os.pathr   r   r5   IPython.core.getipythonr   spyder_kernels.py3compatr   r   objectr   r   r	   r
   <module>rR      s          



 / / / / / / ( ( ( ( ( (  &[/ [/ [/ [/ [/v [/ [/ [/ [/ [/r	   