o
    f`$                     @   s  d dl mZ zd dlmZ W n ey   eefZY nw d dlZd dl	m
Z
 zd dlmZ W n ey?   G dd deZY nw e Zdd	lmZ d
dlmZ d
dlmZ G dd deZG dd deZG dd deZdd Zdd Zdd ZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"eZ G d#d$ d$eZ!dGd&d'Z"d(d) Z#dGd*d+Z$d,d- Z%d
Z&d.d/ Z'd0d1 Z(dHd2d3Z)dId4d5Z*dId6d7Z+d8d9 Z,dJd;d<Z-d=d> Z.e
dJd?d@Z/dAdB Z0dCdD Z1dEdF Z2dS )K    )absolute_import)
basestringN)contextmanager)localc                   @      e Zd ZdS )_threadlocalN__name__
__module____qualname__ r   r   R/var/www/html/mig_web/myenv/lib/python3.10/site-packages/Cython/Compiler/Errors.pyr      s    r      )open_new_file   )
DebugFlags)Optionsc                   @   r   )
PyrexErrorNr   r   r   r   r   r          r   c                   @   r   )PyrexWarningNr   r   r   r   r   r      r   r   c                   @   r   )CannotSpecializeNr   r   r   r   r   r   "   r   r   c                 C   s   | d }t |trJ d| z| }W n ty    d}Y nw d|td| d d | d  }d|d| d	  f }d
d|df }|S )Nr   zOPlease replace filename strings with Scanning.FileSourceDescriptor instances %rz[unprintable code]
 r      z
...
%s%s^
 r   z%s
%s%s
z<------------------------------------------------------------)
isinstanceany_string_type	get_linesUnicodeDecodeErrorjoinmax)positionsourceFsr   r   r   context%   s   $r$   c                 C   s&   | rd| d   | d | d f S dS )Nz
%s:%d:%d: r   r   r   r   )get_error_description)r    r   r   r   format_position4   s
   r&   c                 C   s*   |rt |}t|}d||| pdf } | S )Nz%
Error compiling Cython file:
%s
%s%sr   )r&   r$   )messager    pos_strcontr   r   r   format_error:   s
   r*   c                   @   s   e Zd ZdddZdd ZdS )CompileErrorNr   c                 C   s:   || _ || _t||| _d| _t| | j ||f| _d S )NF)r    message_onlyr*   formatted_messagereported	Exception__init__argsselfr    r'   r   r   r   r0   C   s   zCompileError.__init__c                 C   s   | j S N)r-   )r3   r   r   r   __str__M      zCompileError.__str__Nr   )r	   r
   r   r0   r5   r   r   r   r   r+   A   s    

r+   c                   @   s   e Zd ZdddZdS )CompileWarningNr   c                 C   s   || _ t| t||  d S r4   )r    r/   r0   r&   r2   r   r   r   r0   R   s   zCompileWarning.__init__r7   r	   r
   r   r0   r   r   r   r   r8   P       r8   c                   @      e Zd Zdd ZdS )InternalErrorc                 C      || _ t| d|  d S )NzInternal compiler error: %sr,   r/   r0   r3   r'   r   r   r   r0   Y   s   
zInternalError.__init__Nr9   r   r   r   r   r<   V       r<   c                   @   r;   )
AbortErrorc                 C   r=   )NzAbort error: %sr>   r?   r   r   r   r0   a   s   zAbortError.__init__Nr9   r   r   r   r   rA   ^   r@   rA   c                   @   s   e Zd ZdddZdS )CompilerCrashNc                 C   s   |rd| }nd}|| _ |rd||f }|r&dd l}|dd|| 7 }|r8|s.|d7 }|d|jj|f 7 }t| || |||||f| _d S )N
zCompiler crash in %s%sr   z/

Compiler crash traceback from this point on:
r   z%s: %s)	r,   	tracebackr   	format_tb	__class__r	   r+   r0   r1   )r3   posr$   r'   cause
stacktracerD   r   r   r   r0   g   s&   
zCompilerCrash.__init__r4   r9   r   r   r   r   rB   e   r:   rB   c                   @   s   e Zd ZdZdS )NoElementTreeInstalledExceptionzcraised when the user enabled options.gdb_debug but no ElementTree
    implementation was found
    N)r	   r
   r   __doc__r   r   r   r   rJ   }   s    rJ   Tc                 C   s8   | d ur
t | t_nd t_|rtjt_nd t_dt_d S Nr   )r   threadlocalcython_errors_listing_filesysstderrcython_errors_echo_filecython_errors_count)pathecho_to_stderrr   r   r   open_listing_file   s   

rU   c                   C   s   t jrt j  d t _d S d S r4   )rM   rN   closer   r   r   r   close_listing_file   s   

rW   c              	   C   s
  t j}|r|r|d |  d S | jrd S d| _zd|  }W n ty6   tt| ddt| dd d }Y nw t j}|rVz|| W n tyU   ||	dd	 Y nw t j
}|ruz|| W n tyt   ||	dd	 Y nw t  jd
7  _tjrtdd S )NTz%s
r,   z[unprintable exception message]r    rC   ASCIIreplacer   zfatal errors)rM   cython_errors_stackappendr.   UnicodeEncodeErrorr*   getattrrN   writeencoderQ   rR   r   	fast_failrA   )err	use_stackerror_stacklinelisting_file	echo_filer   r   r   report_error   s:   

rh   c                 C   s4   | d u rt |t| |}tjrt|t| |S r4   )r<   r+   r   debug_exception_on_errorr/   rh   )r    r'   rb   r   r   r   error   s   
rj   c              	   C   s8   z|  | W d S  ty   |  |dd Y d S w )NasciirZ   )r_   r]   r`   )filere   r   r   r   _write_file_encode   s
   rm   c                 C   sL   |j d sd S t| |}d| }tj}|rt|| tj}|r$t|| |S )Nshow_performance_hintszperformance hint: %s
)
directivesr8   rM   rN   rm   rQ   )r    r'   envwarnre   rf   rg   r   r   r   performance_hint   s   



rr   c                 C   sJ   |t k rd S t| |}d| }tj}|rt|| tj}|r#t|| |S )Nz	note: %s
)LEVELr8   rM   rN   rm   rQ   r    r'   levelrq   re   rf   rg   r   r   r   r'      s   


r'   c                 C   s^   |t k rd S tjr| rt| |S t| |}d| }tj}|r#t|| tj}|r-t|| |S Nzwarning: %s
)	rs   r   warning_errorsrj   r8   rM   rN   rm   rQ   rt   r   r   r   warning   s   




rx   c                 C   sf   |t k rd S tj}||v rd S t| |}d| }tj}|r"t|| tj}|r,t|| || |S rv   )rs   rM   cython_errors_warn_once_seenr8   rN   rm   rQ   add)r    r'   ru   warn_once_seenrq   re   rf   rg   r   r   r   	warn_once   s   



r|   c                  C   s   g } t j|  | S r4   )rM   r[   r\   )errorsr   r   r   hold_errors  s   r~   Fc                 C   s(   t j }| s|D ]}t| q	d S d S r4   )rM   r[   poprh   )ignoreheld_errorsrb   r   r   r   release_errors  s   

r   c                   C   s
   t jd S )NrX   )rM   r[   r   r   r   r   r     s   
r   c              	   c   s,    t  }z|V  W t| d d S t| d w )N)r   )r~   r   )r   r}   r   r   r   local_errors  s
   r   c                   C   s$   dt _d t _d t _t t _g t _d S rL   )rM   rR   rN   rQ   setry   r[   r   r   r   r   init_thread   s
   
r   c                   C   s   t j  t jd d = d S r4   )rM   ry   clearr[   r   r   r   r   reset'  s   
r   c                   C   s   t jS r4   )rM   rR   r   r   r   r   get_errors_count+  r6   r   )T)r   )r   )F)3
__future__r   __builtin__r   r   ImportErrorbytesstrrO   
contextlibr   	threadingr   r   objectrM   Utilsr   r   r   r   r/   r   r   r   r$   r&   r*   r+   r8   r<   rA   rB   rJ   rU   rW   rh   rj   rs   rm   rr   r'   rx   r|   r~   r   r   r   r   r   r   r   r   r   r   <module>   s^   







