Format: application/x-python-code
⬇ Download File (6.9 KB)
   1  o
   2  
   3  ��h�"�@s�dZddlZddlZddlmZddlmZddlZddl	m
   4  Z
   5  ddlmZddl
   6  mZddlmZdd	l
   7  mZdd
   8  lmZmZddlZdZdZGd
   9  d�d�Zdeededejddfdd�ZdS)ztsys.excepthook for IPython itself, leaves a detailed report on disk.
  10  
  11  Authors:
  12  
  13  * Fernando Perez
  14  * Brian E. Granger
  15  �N)�pformat)�Path)�ultratb)�Application)�author_email)�sys_info)�__version__)�Optional�Dicta�Oops, {app_name} crashed. We do our best to make it stable, but...
  16  
  17  A crash report was automatically generated with the following information:
  18    - A verbatim copy of the crash traceback.
  19    - A copy of your input history during this session.
  20    - Data on your current {app_name} configuration.
  21  
  22  It was left in the file named:
  23  	'{crash_report_fname}'
  24  If you can email this file to the developers, the information in it will help
  25  them in understanding and correcting the problem.
  26  
  27  You can mail it to: {contact_name} at {contact_email}
  28  with the subject '{app_name} Crash Report'.
  29  
  30  If you want to do it now, the following command will work (under Unix):
  31  mail -s '{app_name} Crash Report' {contact_email} < {crash_report_fname}
  32  
  33  In your email, please also include information about:
  34  - The operating system under which the crash happened: Linux, macOS, Windows,
  35    other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2,
  36    Windows 10 Pro), and whether it is 32-bit or 64-bit;
  37  - How {app_name} was installed: using pip or conda, from GitHub, as part of
  38    a Docker container, or other, providing more detail if possible;
  39  - How to reproduce the crash: what exact sequence of instructions can one
  40    input to get the same crash? Ideally, find a minimal yet complete sequence
  41    of instructions that yields the crash.
  42  
  43  To ensure accurate tracking of this issue, please file a report about it at:
  44  {bug_tracker}
  45  a�
  46  If you suspect this is an IPython {version} bug, please report it at:
  47      https://github.com/ipython/ipython/issues
  48  or send an email to the mailing list at {email}
  49  
  50  You can print a more detailed traceback right now with "%tb", or use "%debug"
  51  to interactively debug it.
  52  
  53  Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
  54      {config}Application.verbose_crash=True
  55  c
  56  @s�eZdZUdZeZdZeee	efe
  57  d<					ddede	ed	e	ed
  58  e	ededefd
  59  d�Z
  60  deededejddfdd�Zdedefdd�ZdS)�CrashHandlerz�Customizable crash handlers for IPython applications.
  61  
  62      Instances of this class provide a :meth:`__call__` method which can be
  63      used as a ``sys.excepthook``.  The :meth:`__call__` signature is::
  64  
  65          def __call__(self, etype, evalue, etb)
  66      zO
  67  
  68  ***************************************************************************
  69  
  70  �infoNTF�app�contact_name�
  71  contact_email�bug_tracker�show_crash_traceback�call_pdbcCs:d|j|_||_||_||_t|j||||jd�|_dS)a�Create a new crash handler
  72  
  73          Parameters
  74          ----------
  75          app : Application
  76              A running :class:`Application` instance, which will be queried at
  77              crash time for internal information.
  78          contact_name : str
  79              A string with the name of the person to contact.
  80          contact_email : str
  81              A string with the email address of the contact.
  82          bug_tracker : str
  83              A string with the URL for your project's bug tracker.
  84          show_crash_traceback : bool
  85              If false, don't print the crash traceback on stderr, only generate
  86              the on-disk report
  87          call_pdb
  88              Whether to call pdb on crash
  89  
  90          Attributes
  91          ----------
  92          These instances contain some non-argument attributes which allow for
  93          further customization of the crash handler's behavior. Please see the
  94          source for further details.
  95  
  96          zCrash_report_%s.txt)Zapp_namerrr�crash_report_fnameN)�namerr
  97  rr�dictr)�selfr
  98  rrrrr�r�Oc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/crashhandler.py�__init__gs#�zCrashHandler.__init__�etype�evalue�etb�returncCsbtjt_d}t|jdd�}|durt|t�sJ�t|�}nt��}|�	�s)t��}||j
  99  }t|�|_
 100  t|�|jd<tj
 101  |d|jd�}|jrN||||�dS|j|||dd�}	|jrat|	tjd	�z	t|d
 102  dd�}
 103  Wn
 104  td
 105  tjd	�YdS|
 106  �(tdtjd	�t|jjdi|j��tjd	�|
 107  �|�t|	���Wd�n1s�wYt�d�dS)z<Handle an exception, call for compatible with sys.excepthookZNoColor�ipython_dirNrT)�color_schemeZlong_headerr�)�context��file�wzutf-8)�encodingz&Could not create crash report on disk.zH
 108  **********************************************************************
 109  z.Hit <Enter> to quit (your terminal may close):r)�sys�__excepthook__�
 110  excepthook�getattrr
 111  �
 112  isinstance�strr�cwd�is_dirrrrZ	VerboseTBr�textr�print�stderr�open�message_template�format�write�make_report�builtin_mod�input)rrrrrrZrptdirZreport_nameZ	TBhandler�	traceback�reportrrr�__call__�sD
 113  
 114  
 115  ��zCrashHandler.__call__r8cCsx|j}dg}|j}|t��zt|jj�}||�|d|jj�|d�||�WnY||d|�d�|�S)z*Return a string containing a crash report.zi***************************************************************************
 116  
 117  IPython post-mortem report
 118  
 119  zApplication name: %s
 120  
 121  z'Current user configuration structure:
 122  
 123  zCrash traceback:
 124  
 125  �)�section_sep�appendrrr
 126  �configr�join)rr8Zsec_sepr9Zrpt_addr>rrrr5�s
 127  
 128  zCrashHandler.make_report)NNNTF)�__name__�
 129  __module__�__qualname__�__doc__�_default_message_templater2r<r
 130  r+r	�__annotations__r�boolr�type�
 131  BaseException�types�
 132  TracebackTyper:r5rrrrrZsB
 133  ������
 134  �.���
 135  �?rrr�tbrcCsJt�|||�ddlm}|��rd}nd}ttjt|t	d�t
 136  jd�dS)zAa light excepthook, adding a small message to the usual tracebackr)�InteractiveShellz%config zc.)�emailr>�versionr"N)r8�print_exceptionZIPython.core.interactiveshellrLZinitializedr/�_lite_message_templater3rrNr&r0)rrrKrLr>rrr�crash_handler_lite�srQ)rCr&r8�pprintr�pathlibr�builtinsr6ZIPython.corerZIPython.core.applicationrZIPython.core.releaserZIPython.utils.sysinforrrN�typingr	r
 137  rIrDrPrrGrHrJrQrrrr�<module>s4!
 138  ����