
    "e                         d Z ddlZ	 ddlZej                  Zd Zd Zd Z	 e	       Z
g Zd Zy#   e ej                               ZY 1xY w)z
Utility for saving locals.
    Nc                      t         d uS N)save_locals_impl     C/usr/lib/python3/dist-packages/_pydevd_bundle/pydevd_save_locals.pyis_save_locals_availabler	      s    4''r   c                 Z    t        | t              syt        	 t        |        yy#  Y yxY w)a  
    Copy values from locals_dict into the fast stack slots in the given frame.

    Note: the 'save_locals' branch had a different approach wrapping the frame (much more code, but it gives ideas
    on how to save things partially, not the 'whole' locals).
    N)
isinstance
frame_typer   )frames    r   save_localsr      s3     eZ(#	U# $	s   & *c                      	 dt         j                  v rddl} | j                  dt         j                  v rfd}|S 	 ddlj
                  j                  fd}|S #  Y 'xY w#  Y yxY w)a[  
    Factory for the 'save_locals_impl' method. This may seem like a complicated pattern but it is essential that the method is created at
    module load time. Inner imports after module load time would cause an occasional debugger deadlock due to the importer lock and debugger
    lock being taken in different order in  different threads.
    __pypy__r   Nc                      |        y r   r   )r   r   s    r   save_locals_pypy_implz4make_save_locals_impl.<locals>.save_locals_pypy_impl3   s    E"r   c                 T     j                  |       j                  d             y )Nr   )	py_objectc_int)r   ctypeslocals_to_fasts    r   save_locals_ctypes_implz6make_save_locals_impl.<locals>.save_locals_ctypes_impl?   s     6++E2FLLODr   )sysbuiltin_module_namesr   r   r   	pythonapiPyFrame_LocalsToFast)r   r   r   r   r   r   s      @@@r   make_save_locals_implr   $   s    )111"11K 111# )(
'))>>
	E '&) s   "A# A* #A'*A.c                 <   | J d }t        |      j                  |       }| j                         D ]1  \  }}||j                  |t              us||j
                  }|||<   3 |r||j
                  }|D ]  }	 ||=  |t        |       y y # t        $ r Y #w xY wr   )set
differenceitemsget	_SENTINELf_localsKeyErrorr   )updated_globalsinitial_globalsr   r$   removedkeyvals          r   update_globals_and_localsr+   L   s     &&&H/"--o>G#))+  So))#y99 !>>HSM   ~~H 	CSM	 E   s   ;B	BB)__doc__r   types	FrameTyper   type	_getframer	   r   r   r   r#   r+   r   r   r   <module>r1      s_    'J
($ F )* 	%E'mcmmo&Js	   . A	