
    Mh+"                         d Z ddlZddlZddlmZ ddlmZ ddlZddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlZdZdZ G d d          Zdee         dedej        ddfdZdS )ztsys.excepthook for IPython itself, leaves a detailed report on disk.

Authors:

* Fernando Perez
* Brian E. Granger
    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...

A crash report was automatically generated with the following information:
  - A verbatim copy of the crash traceback.
  - A copy of your input history during this session.
  - Data on your current {app_name} configuration.

It was left in the file named:
	'{crash_report_fname}'
If you can email this file to the developers, the information in it will help
them in understanding and correcting the problem.

You can mail it to: {contact_name} at {contact_email}
with the subject '{app_name} Crash Report'.

If you want to do it now, the following command will work (under Unix):
mail -s '{app_name} Crash Report' {contact_email} < {crash_report_fname}

In your email, please also include information about:
- The operating system under which the crash happened: Linux, macOS, Windows,
  other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2,
  Windows 10 Pro), and whether it is 32-bit or 64-bit;
- How {app_name} was installed: using pip or conda, from GitHub, as part of
  a Docker container, or other, providing more detail if possible;
- How to reproduce the crash: what exact sequence of instructions can one
  input to get the same crash? Ideally, find a minimal yet complete sequence
  of instructions that yields the crash.

To ensure accurate tracking of this issue, please file a report about it at:
{bug_tracker}
a  
If you suspect this is an IPython {version} bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at {email}

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    {config}Application.verbose_crash=True
c                       e Zd ZU dZeZdZeee	e         f         e
d<   	 	 	 	 	 ddede	e         d	e	e         d
e	e         dedefdZdee         dedej        ddfdZdedefdZdS )CrashHandlerzCustomizable crash handlers for IPython applications.

    Instances of this class provide a :meth:`__call__` method which can be
    used as a ``sys.excepthook``.  The :meth:`__call__` signature is::

        def __call__(self, etype, evalue, etb)
    zO

***************************************************************************

infoNTFappcontact_namecontact_emailbug_trackershow_crash_tracebackcall_pdbc                     d|j         z  | _        || _        || _        || _        t          |j         |||| j                  | _        dS )a  Create a new crash handler

        Parameters
        ----------
        app : Application
            A running :class:`Application` instance, which will be queried at
            crash time for internal information.
        contact_name : str
            A string with the name of the person to contact.
        contact_email : str
            A string with the email address of the contact.
        bug_tracker : str
            A string with the URL for your project's bug tracker.
        show_crash_traceback : bool
            If false, don't print the crash traceback on stderr, only generate
            the on-disk report
        call_pdb
            Whether to call pdb on crash

        Attributes
        ----------
        These instances contain some non-argument attributes which allow for
        further customization of the crash handler's behavior. Please see the
        source for further details.

        zCrash_report_%s.txt)app_namer   r   r   crash_report_fnameN)namer   r   r   r   dictr   )selfr   r   r   r   r   r   s          Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/core/crashhandler.py__init__zCrashHandler.__init__f   sZ    F #8#("B $8!CH#/$1"-)-)@	B B B			    etypeevalueetbreturnc                 2   t           j        t           _        t          | j        dd          }|'t          |t                    sJ t          |          }nt          j                    }|	                                st          j                    }|| j
        z  }t          |          | _
        t          |          | j        d<   t          j        dd| j                  }| j        r ||||           dS |                    |||d          }| j        rt#          |t           j        	           	 t'          |d
d          }	n##  t#          dt           j        	           Y dS xY w|	5  t#          dt           j        	           t#           | j        j        di | j        t           j        	           |	                    |                     t          |                               ddd           n# 1 swxY w Y   t1          j        d           dS )z<Handle an exception, call for compatible with sys.excepthookipython_dirNr   nocolorT)
theme_namelong_headerr      )contextfilewzutf-8)encodingz&Could not create crash report on disk.zH
**********************************************************************
z.Hit <Enter> to quit (your terminal may close): )sys__excepthook__
excepthookgetattrr   
isinstancestrr   cwdis_dirr   r   r   	VerboseTBr   textr   printstderropenmessage_templateformatwritemake_reportbuiltin_modinput)
r   r   r   r    r#   rptdirreport_name	TBhandler	tracebackreports
             r   __call__zCrashHandler.__call__   sM    + dht<<"k3/////+&&FFXZZF}} 	 XZZFt66 #&k"2"2*-k*:*:	&'% ]
 
 
	
 = 	DIeF3'''F!uVCCCI $ 	.)#*----	+sW===FF	:LLLLFF 	; 	;"4444.$'.;;;;#*MMMM LL))#i..99:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	JKKKKKs   3E E&+BG88G<?G<rD   c                 T   | j         }dg}|j        } |t                                 	 t          | j        j                  } ||            |d| j        j        z              |d            ||           n#  Y nxY w ||dz   |z              d                    |          S )z*Return a string containing a crash report.zi***************************************************************************

IPython post-mortem report

zApplication name: %s

z'Current user configuration structure:

zCrash traceback:

 )section_sepappendr   r   r   configr   join)r   rD   sec_seprE   rpt_addrK   s         r   r>   zCrashHandler.make_report   s     "@A-

	TX_--FGGG.>???G?@@@GFOOOO	D..:;;;wwvs   AA= =B)NNNTF)__name__
__module____qualname____doc___default_message_templater;   rI   r   r3   r
   __annotations__r   boolr   typeBaseExceptiontypesTracebackTyperF   r>   r-   r   r   r   r   Y   s0          1&K
sHSM!
""""
 '+'+%)%),B ,B,B sm,B  }	,B
 c],B #,B ,B ,B ,B ,B\:LM":L :L  	:L
 
:L :L :L :LxS S      r   r   r   r   tbr!   c                     t          j        | ||           ddlm} |                                rd}nd}t          t                              t          |t                    t          j                   dS )zAa light excepthook, adding a small message to the usual tracebackr   )InteractiveShellz%config zc.)emailrK   versionr)   N)rD   print_exceptionIPython.core.interactiveshellr\   initializedr8   _lite_message_templater<   r   r^   r.   r9   )r   r   rZ   r\   rK   s        r   crash_handler_literc      s     eVR000>>>>>>##%%  	
 
'
'l6SZ
'
[
[beblmmmmmmr   )rR   r.   rD   pprintr   pathlibr   builtinsr?   IPython.corer   IPython.core.applicationr   IPython.core.releaser   IPython.utils.sysinfor   r	   r^   typingr
   r   rX   rS   rb   r   rV   rW   rY   rc   r-   r   r   <module>rl      sc   ( 


                                 0 0 0 0 0 0 - - - - - - * * * * * * 7 7 7 7 7 7 ! ! ! ! ! ! ! !  B
 J J J J J J J JZnn(5n;@;Nn	n n n n n nr   