Only import faulthandler if available

This commit is contained in:
Florian Bruhin 2014-02-10 22:40:21 +01:00
parent 903d9e7557
commit fca70a0c6f

View File

@ -21,10 +21,18 @@ import os
import sys import sys
import logging import logging
import subprocess import subprocess
import faulthandler
from signal import signal, SIGINT from signal import signal, SIGINT
from argparse import ArgumentParser from argparse import ArgumentParser
# Print a nice traceback on segfault -- only available on Python 3.3+, but if
# it's unavailable, it doesn't matter much.
try:
import faulthandler
except ImportError:
pass
else:
faulthandler.enable()
# This is a really old place to do this, but we have to do this before # This is a really old place to do this, but we have to do this before
# importing PyQt or it won't work. # importing PyQt or it won't work.
# See https://bugreports.qt-project.org/browse/QTBUG-36099 # See https://bugreports.qt-project.org/browse/QTBUG-36099
@ -66,9 +74,6 @@ class QuteBrowser(QApplication):
super().__init__(sys.argv) super().__init__(sys.argv)
sys.excepthook = self._exception_hook sys.excepthook = self._exception_hook
# Handle segfaults
faulthandler.enable()
self._parseopts() self._parseopts()
self._initlog() self._initlog()
self._initmisc() self._initmisc()