Skip to content


don't use crash_handler by default #1008

merged 3 commits into from

2 participants

IPython member

Now the excepthook shows a regular traceback, with a brief message about reporting bugs and how to enable to the big crash handler. Adding a more/0 to interact inside if more:, I get:

In [1]: if 1:
Traceback (most recent call last):
  File "/prefix/bin/ipython", line 9, in <module>
    load_entry_point('', 'console_scripts', 'ipython')()
  File "/prefix/IPython/frontend/terminal/", line 393, in launch_new_instance
  File "/prefix/IPython/frontend/terminal/", line 367, in start
  File "/prefix/IPython/frontend/terminal/", line 220, in mainloop
  File "/prefix/IPython/frontend/terminal/", line 288, in interact
ZeroDivisionError: integer division or modulo by zero

If you suspect this is an IPython bug, please report it at:
or send an email to the mailing list at

You can enable a much more verbose crash handler with:
    %config Application.verbose_crash=True

small fixes along the way:

  • current Application added to configurables list, for use in %config.
  • email addresses in full crash reports changed to ipython-dev, so they don't go straight to individual users.

Should close #695, and ameliorate #833 (doesn't fix the bug, but the message is more sensible)

minrk added some commits
@minrk minrk include parent Application in InteractiveShell.configurables
for use in %config magic
@minrk minrk use ipython-dev as the email address for crash reports a6e5b20
@minrk minrk Don't use crash_handler by default
adds crash_handler_lite for adding a short message after a regular

Application.verbose_crash configurable determines which to use
IPython member

Great! Code looks clean, tested it. Nice to get rid of those endless crash reports... Merging now.

@fperez fperez merged commit 493f6d4 into ipython:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 17, 2011
  1. @minrk

    include parent Application in InteractiveShell.configurables

    minrk committed
    for use in %config magic
  2. @minrk
  3. @minrk

    Don't use crash_handler by default

    minrk committed
    adds crash_handler_lite for adding a short message after a regular
    Application.verbose_crash configurable determines which to use
21 IPython/core/
@@ -137,6 +137,11 @@ def _config_files_default(self):
profile, then they will be staged into the new directory. Otherwise,
default config files will be automatically generated.
+ verbose_crash = Bool(False, config=True,
+ help="""Create a massive crash report when IPython enconters what may be an
+ internal error. The default is to append a short message to the
+ usual traceback""")
# The class to use as the crash handler.
crash_handler_class = Type(crashhandler.CrashHandler)
@@ -154,11 +159,23 @@ def __init__(self, **kwargs):
def init_crash_handler(self):
"""Create a crash handler, typically setting sys.excepthook to it."""
self.crash_handler = self.crash_handler_class(self)
- sys.excepthook = self.crash_handler
+ sys.excepthook = self.excepthook
def unset_crashhandler():
sys.excepthook = sys.__excepthook__
+ def excepthook(self, etype, evalue, tb):
+ """this is sys.excepthook after init_crashhandler
+ set self.verbose_crash=True to use our full crashhandler, instead of
+ a regular traceback with a short message (crash_handler_lite)
+ """
+ if self.verbose_crash:
+ return self.crash_handler(etype, evalue, tb)
+ else:
+ return crashhandler.crash_handler_lite(etype, evalue, tb)
def _ipython_dir_changed(self, name, old, new):
if old in sys.path:
27 IPython/core/
@@ -21,9 +21,11 @@
import os
import sys
+import traceback
from pprint import pformat
from IPython.core import ultratb
+from IPython.core.release import author_email
from IPython.utils.sysinfo import sys_info
@@ -54,6 +56,15 @@
+_lite_message_template = """
+If you suspect this is an IPython bug, please report it at:
+or send an email to the mailing list at {email}
+You can enable a much more verbose traceback with:
+ {config}Application.verbose_crash=True
class CrashHandler(object):
"""Customizable crash handlers for IPython applications.
@@ -161,7 +172,7 @@ def __call__(self, etype, evalue, etb):
# Construct report on disk
- raw_input("Hit <Enter> to quit this message (your terminal may close):")
+ raw_input("Hit <Enter> to quit (your terminal may close):")
def make_report(self,traceback):
"""Return a string containing a crash report."""
@@ -184,3 +195,17 @@ def make_report(self,traceback):
return ''.join(report)
+def crash_handler_lite(etype, evalue, tb):
+ """a light excepthook, adding a small message to the usual traceback"""
+ traceback.print_exception(etype, evalue, tb)
+ from IPython.core.interactiveshell import InteractiveShell
+ if InteractiveShell.initialized():
+ # we are in a Shell environment, give %magic example
+ config = "%config "
+ else:
+ # we are not in a shell, show generic config
+ config = "c."
+ print >> sys.stderr, _lite_message_template.format(email=author_email, config=config)
5 IPython/frontend/terminal/
@@ -81,8 +81,8 @@ class IPAppCrashHandler(CrashHandler):
def __init__(self, app):
contact_name = release.authors['Fernando'][0]
- contact_email = release.authors['Fernando'][1]
- bug_tracker = ''
+ contact_email = release.author_email
+ bug_tracker = ''
app, contact_name, contact_email, bug_tracker
@@ -320,6 +320,7 @@ def init_shell(self): = TerminalInteractiveShell.instance(config=self.config,
display_banner=False, profile_dir=self.profile_dir,
def init_banner(self):
"""optionally display the banner"""
4 IPython/parallel/apps/
@@ -58,8 +58,8 @@ class ParallelCrashHandler(CrashHandler):
def __init__(self, app):
contact_name = release.authors['Min'][0]
- contact_email = release.authors['Min'][1]
- bug_tracker = ''
+ contact_email = release.author_email
+ bug_tracker = ''
app, contact_name, contact_email, bug_tracker
1 IPython/zmq/
@@ -780,6 +780,7 @@ def print_tb(etype, evalue, stb):
def init_shell(self): =
Something went wrong with that request. Please try again.