##// END OF EJS Templates
Don't use crash_handler by default...
MinRK -
Show More
@@ -137,6 +137,11 b' class BaseIPythonApplication(Application):'
137 137 profile, then they will be staged into the new directory. Otherwise,
138 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 146 # The class to use as the crash handler.
142 147 crash_handler_class = Type(crashhandler.CrashHandler)
@@ -154,11 +159,23 b' class BaseIPythonApplication(Application):'
154 159 def init_crash_handler(self):
155 160 """Create a crash handler, typically setting sys.excepthook to it."""
156 161 self.crash_handler = self.crash_handler_class(self)
157 sys.excepthook = self.crash_handler
162 sys.excepthook = self.excepthook
158 163 def unset_crashhandler():
159 164 sys.excepthook = sys.__excepthook__
160 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 179 def _ipython_dir_changed(self, name, old, new):
163 180 if old in sys.path:
164 181 sys.path.remove(old)
@@ -21,9 +21,11 b' Authors:'
21 21
22 22 import os
23 23 import sys
24 import traceback
24 25 from pprint import pformat
25 26
26 27 from IPython.core import ultratb
28 from IPython.core.release import author_email
27 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 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 69 class CrashHandler(object):
59 70 """Customizable crash handlers for IPython applications.
@@ -161,7 +172,7 b' class CrashHandler(object):'
161 172 # Construct report on disk
162 173 report.write(self.make_report(traceback))
163 174 report.close()
164 raw_input("Hit <Enter> to quit this message (your terminal may close):")
175 raw_input("Hit <Enter> to quit (your terminal may close):")
165 176
166 177 def make_report(self,traceback):
167 178 """Return a string containing a crash report."""
@@ -184,3 +195,17 b' class CrashHandler(object):'
184 195
185 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
General Comments 0
You need to be logged in to leave comments. Login now