Show More
@@ -137,6 +137,11 b' class BaseIPythonApplication(Application):' | |||||
137 | profile, then they will be staged into the new directory. Otherwise, |
|
137 | profile, then they will be staged into the new directory. Otherwise, | |
138 | default config files will be automatically generated. |
|
138 | default config files will be automatically generated. | |
139 | """) |
|
139 | """) | |
|
140 | ||||
|
141 | verbose_crash = Bool(False, config=True, | |||
|
142 | help="""Create a massive crash report when IPython enconters what may be an | |||
|
143 | internal error. The default is to append a short message to the | |||
|
144 | usual traceback""") | |||
140 |
|
145 | |||
141 | # The class to use as the crash handler. |
|
146 | # The class to use as the crash handler. | |
142 | crash_handler_class = Type(crashhandler.CrashHandler) |
|
147 | crash_handler_class = Type(crashhandler.CrashHandler) | |
@@ -154,11 +159,23 b' class BaseIPythonApplication(Application):' | |||||
154 | def init_crash_handler(self): |
|
159 | def init_crash_handler(self): | |
155 | """Create a crash handler, typically setting sys.excepthook to it.""" |
|
160 | """Create a crash handler, typically setting sys.excepthook to it.""" | |
156 | self.crash_handler = self.crash_handler_class(self) |
|
161 | self.crash_handler = self.crash_handler_class(self) | |
157 |
sys.excepthook = self. |
|
162 | sys.excepthook = self.excepthook | |
158 | def unset_crashhandler(): |
|
163 | def unset_crashhandler(): | |
159 | sys.excepthook = sys.__excepthook__ |
|
164 | sys.excepthook = sys.__excepthook__ | |
160 | atexit.register(unset_crashhandler) |
|
165 | atexit.register(unset_crashhandler) | |
161 |
|
166 | |||
|
167 | def excepthook(self, etype, evalue, tb): | |||
|
168 | """this is sys.excepthook after init_crashhandler | |||
|
169 | ||||
|
170 | set self.verbose_crash=True to use our full crashhandler, instead of | |||
|
171 | a regular traceback with a short message (crash_handler_lite) | |||
|
172 | """ | |||
|
173 | ||||
|
174 | if self.verbose_crash: | |||
|
175 | return self.crash_handler(etype, evalue, tb) | |||
|
176 | else: | |||
|
177 | return crashhandler.crash_handler_lite(etype, evalue, tb) | |||
|
178 | ||||
162 | def _ipython_dir_changed(self, name, old, new): |
|
179 | def _ipython_dir_changed(self, name, old, new): | |
163 | if old in sys.path: |
|
180 | if old in sys.path: | |
164 | sys.path.remove(old) |
|
181 | sys.path.remove(old) |
@@ -21,9 +21,11 b' Authors:' | |||||
21 |
|
21 | |||
22 | import os |
|
22 | import os | |
23 | import sys |
|
23 | import sys | |
|
24 | import traceback | |||
24 | from pprint import pformat |
|
25 | from pprint import pformat | |
25 |
|
26 | |||
26 | from IPython.core import ultratb |
|
27 | from IPython.core import ultratb | |
|
28 | from IPython.core.release import author_email | |||
27 | from IPython.utils.sysinfo import sys_info |
|
29 | from IPython.utils.sysinfo import sys_info | |
28 |
|
30 | |||
29 | #----------------------------------------------------------------------------- |
|
31 | #----------------------------------------------------------------------------- | |
@@ -54,6 +56,15 b' To ensure accurate tracking of this issue, please file a report about it at:' | |||||
54 | {bug_tracker} |
|
56 | {bug_tracker} | |
55 | """ |
|
57 | """ | |
56 |
|
58 | |||
|
59 | _lite_message_template = """ | |||
|
60 | If you suspect this is an IPython bug, please report it at: | |||
|
61 | https://github.com/ipython/ipython/issues | |||
|
62 | or send an email to the mailing list at {email} | |||
|
63 | ||||
|
64 | You can enable a much more verbose traceback with: | |||
|
65 | {config}Application.verbose_crash=True | |||
|
66 | """ | |||
|
67 | ||||
57 |
|
68 | |||
58 | class CrashHandler(object): |
|
69 | class CrashHandler(object): | |
59 | """Customizable crash handlers for IPython applications. |
|
70 | """Customizable crash handlers for IPython applications. | |
@@ -161,7 +172,7 b' class CrashHandler(object):' | |||||
161 | # Construct report on disk |
|
172 | # Construct report on disk | |
162 | report.write(self.make_report(traceback)) |
|
173 | report.write(self.make_report(traceback)) | |
163 | report.close() |
|
174 | report.close() | |
164 |
raw_input("Hit <Enter> to quit |
|
175 | raw_input("Hit <Enter> to quit (your terminal may close):") | |
165 |
|
176 | |||
166 | def make_report(self,traceback): |
|
177 | def make_report(self,traceback): | |
167 | """Return a string containing a crash report.""" |
|
178 | """Return a string containing a crash report.""" | |
@@ -184,3 +195,17 b' class CrashHandler(object):' | |||||
184 |
|
195 | |||
185 | return ''.join(report) |
|
196 | return ''.join(report) | |
186 |
|
197 | |||
|
198 | ||||
|
199 | def crash_handler_lite(etype, evalue, tb): | |||
|
200 | """a light excepthook, adding a small message to the usual traceback""" | |||
|
201 | traceback.print_exception(etype, evalue, tb) | |||
|
202 | ||||
|
203 | from IPython.core.interactiveshell import InteractiveShell | |||
|
204 | if InteractiveShell.initialized(): | |||
|
205 | # we are in a Shell environment, give %magic example | |||
|
206 | config = "%config " | |||
|
207 | else: | |||
|
208 | # we are not in a shell, show generic config | |||
|
209 | config = "c." | |||
|
210 | print >> sys.stderr, _lite_message_template.format(email=author_email, config=config) | |||
|
211 |
@@ -81,8 +81,8 b' class IPAppCrashHandler(CrashHandler):' | |||||
81 |
|
81 | |||
82 | def __init__(self, app): |
|
82 | def __init__(self, app): | |
83 | contact_name = release.authors['Fernando'][0] |
|
83 | contact_name = release.authors['Fernando'][0] | |
84 |
contact_email = release.author |
|
84 | contact_email = release.author_email | |
85 | bug_tracker = 'http://github.com/ipython/ipython/issues' |
|
85 | bug_tracker = 'https://github.com/ipython/ipython/issues' | |
86 | super(IPAppCrashHandler,self).__init__( |
|
86 | super(IPAppCrashHandler,self).__init__( | |
87 | app, contact_name, contact_email, bug_tracker |
|
87 | app, contact_name, contact_email, bug_tracker | |
88 | ) |
|
88 | ) | |
@@ -320,6 +320,7 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):' | |||||
320 | self.shell = TerminalInteractiveShell.instance(config=self.config, |
|
320 | self.shell = TerminalInteractiveShell.instance(config=self.config, | |
321 | display_banner=False, profile_dir=self.profile_dir, |
|
321 | display_banner=False, profile_dir=self.profile_dir, | |
322 | ipython_dir=self.ipython_dir) |
|
322 | ipython_dir=self.ipython_dir) | |
|
323 | self.shell.configurables.append(self) | |||
323 |
|
324 | |||
324 | def init_banner(self): |
|
325 | def init_banner(self): | |
325 | """optionally display the banner""" |
|
326 | """optionally display the banner""" |
@@ -58,8 +58,8 b' class ParallelCrashHandler(CrashHandler):' | |||||
58 |
|
58 | |||
59 | def __init__(self, app): |
|
59 | def __init__(self, app): | |
60 | contact_name = release.authors['Min'][0] |
|
60 | contact_name = release.authors['Min'][0] | |
61 |
contact_email = release.author |
|
61 | contact_email = release.author_email | |
62 | bug_tracker = 'http://github.com/ipython/ipython/issues' |
|
62 | bug_tracker = 'https://github.com/ipython/ipython/issues' | |
63 | super(ParallelCrashHandler,self).__init__( |
|
63 | super(ParallelCrashHandler,self).__init__( | |
64 | app, contact_name, contact_email, bug_tracker |
|
64 | app, contact_name, contact_email, bug_tracker | |
65 | ) |
|
65 | ) |
@@ -780,6 +780,7 b' class IPKernelApp(KernelApp, InteractiveShellApp):' | |||||
780 |
|
780 | |||
781 | def init_shell(self): |
|
781 | def init_shell(self): | |
782 | self.shell = self.kernel.shell |
|
782 | self.shell = self.kernel.shell | |
|
783 | self.shell.configurables.append(self) | |||
783 |
|
784 | |||
784 |
|
785 | |||
785 | #----------------------------------------------------------------------------- |
|
786 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now