+
    ^|iN                         R t ^ RIt^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ]P                  ! ]P                  R ]P                   4       4      tRR lt ! R R]P"                  4      tR# )	zCompiler tools with improved interactive support.

Provides compilation machinery similar to codeop, but with caching support so
we can provide interactive tracebacks.

Authors
-------
* Robert Kern
* Fernando Perez
* Thomas Kluyver
N)PyCF_ONLY_AST)contextmanagerc              #   V   "   T F  p\        \        V4      P                  x  K!  	  R # 5iN)getattr
__future__compiler_flag).0fnames   & 9/usr/lib/python3/dist-packages/IPython/core/compilerop.py	<genexpr>r   /   s%      I+G% &j%8FF+Gs   ')c                    \         P                  ! V P                  R4      4      P                  4       pRP	                  WR,          4      # )z]Compute a (probably) unique name for code for caching.

This now expects code to be unicode.
zutf-8z<ipython-input-{0}-{1}>:N   N)hashlibsha1encode	hexdigestformat)codenumberhash_digests   && r   	code_namer   6   s<    
 ,,t{{734>>@K %++F4DEE    c                   p   a  ] tR t^Et o RtR tRR ltR t]R 4       t	R t
R tRR	 lt]R
 4       tRtV tR# )CachingCompilerzFA compiler that caches code compiled from interactive statements.
    c                R    \         P                  P                  V 4       / V n        R # r   )codeopCompile__init___filename_mapselfs   &r   r   CachingCompiler.__init__I   s    %
  r   c                F    \        WW0P                  \        ,          ^4      # )zParse code to an AST with the current compiler flags active.

Arguments are exactly the same as ast.parse (in the standard library),
and are passed to the built-in compile function.)compileflagsr   )r!   sourcefilenamesymbols   &&&&r   	ast_parseCachingCompiler.ast_parseQ   s    
 vm1KQOOr   c                0    \         P                  V n        R# )z&Reset compiler flags to default state.N)r   PyCF_DONT_IMPLY_DEDENTr%   r    s   &r   reset_compiler_flags$CachingCompiler.reset_compiler_flagsX   s     22
r   c                    V P                   # )z;Flags currently active in the compilation process.
        r%   r    s   &r   compiler_flagsCachingCompiler.compiler_flags^   s     zzr   c                    \        W#4      # )aQ  Compute filename given the code, and the cell number.

Parameters
----------
raw_code : str
    The raw cell code.
transformed_code : str
    The executable Python source code to cache and compile.
number : int
    A number which forms part of the code's name. Used for the execution
    counter.

Returns
-------
The computed filename.
)r   )r!   raw_codetransformed_coder   s   &&&&r   get_code_nameCachingCompiler.get_code_named   s    " )22r   c                ^    WP                   9   d   RRV P                   V,          ,          3# R# )a  Return a user-friendly label and name for a code block.

Parameters
----------
name : str
    The name for the code block returned from get_code_name

Returns
-------
A (label, name) pair that can be used in tracebacks, or None if the default formatting should be used.
CellzIn[%s]N)r   )r!   names   &&r   format_code_name CachingCompiler.format_code_namew   s0     %%%8d&8&8&>>>> &r   Nc                    Vf   TpV P                  W1V4      pW P                  V&   \        V4      RVP                  4        Uu. uF  qUR,           NK  	  upV3pV\        P
                  V&   V# u upi )a  Make a name for a block of code, and cache the code.

Parameters
----------
transformed_code : str
    The executable Python source code to cache and compile.
number : int
    A number which forms part of the code's name. Used for the execution
    counter.
raw_code : str
    The raw code before transformation, if None, set to `transformed_code`.

Returns
-------
The name of the cached code (as a string). Pass this as the filename
argument to compilation, so that tracebacks are correctly hooked up.
N
)r6   r   len
splitlines	linecachecache)r!   r5   r   r4   r:   lineentrys   &&&&   r   rB   CachingCompiler.cache   s    $ 'H!!(fE $*4   !%5%@%@%BC%BTD[[%BC	
 !&		 Ds   A/c              #     "   V P                   ( V,          pV P                   V,          V n          R x  V ;P                   V( ,          un         R #   T ;P                   T( ,          un         i ; i5ir   r0   )r!   r%   turn_on_bitss   && r   extra_flagsCachingCompiler.extra_flags   sS      

{U* ZZ%'
	( JJ<-'JDJJ<-'Js   -A/A A/A,,A/)r   r%   )z	<unknown>exec)    N)__name__
__module____qualname____firstlineno____doc__r   r)   r-   propertyr1   r6   r;   rB   r   rH   __static_attributes____classdictcell__)__classdict__s   @r   r   r   E   sR      P3  
3&?,\ ( (r   r   )rK   )rP   r   astr   r   	functoolsr   rA   operatortime
contextlibr   reduceor_all_feature_names	PyCF_MASKr   r   r    r   r   <module>r_      sm   
:         % X\\I+5+G+GIJ		F{(fnn {(r   