U
    *¿if  ã                   @  sL   d dl mZ d dlZd dlZd dlZejdddœdd„ƒZddœd	d
„ZdS )é    )ÚannotationsNÚstr)Úold_nameÚnew_namec              
   c  s‚   z
dV  W nr t k
r| } zT|js$‚ t|jd ƒ}| | |¡}|f}t|jƒdkrd||jdd…  }||_‚ W 5 d}~X Y nX dS )z.
    Rewrite the message of an exception.
    Nr   é   )Ú	ExceptionÚargsr   ÚreplaceÚlen)r   r   ÚerrÚmsgr   © r   úJ/home/mars/bis/venv/lib/python3.8/site-packages/pandas/util/_exceptions.pyÚrewrite_exception   s    
r   Úint)Úreturnc                  C  sh   t  ¡ } ddl}tj |j¡}tj |d¡}tt	| ƒƒD ]*}| | j
}| |¡r^| |¡s^q8q8 qdq8|S )zb
    Find the first place in the stack that is not inside pandas
    (tests notwithstanding).
    r   NÚtests)ÚinspectÚstackZpandasÚosÚpathÚdirnameÚ__file__ÚjoinÚranger
   ÚfilenameÚ
startswith)r   ÚpdZpkg_dirZtest_dirÚnÚfnamer   r   r   Úfind_stack_level   s    
r    )Ú
__future__r   Ú
contextlibr   r   Úcontextmanagerr   r    r   r   r   r   Ú<module>   s   