# Buggy code
def error_and_exit(title, main_text):
    """
    Show a pop-up window and sys.exit() out of Python.

    :param title: the short error description
    :param main_text: the long error description
    """
    # NOTE: We don't want to load all of these imports normally.
    #       Otherwise we will have these unused GUI modules loaded in the main process.
    from PyQt5.QtWidgets import QMainWindow
    from PyQt5.QtCore import pyqtSignal

    from TriblerGUI.single_application import QtSingleApplication
    from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog
    from TriblerGUI.defs import BUTTON_TYPE_NORMAL

    app = QtSingleApplication("Tribler", [])
    if app.is_running():
        sys.exit(1)

    class CustomConfDialog(QMainWindow):
        escape_pressed = pyqtSignal()
        resize_event = pyqtSignal()

        def __init__(self, title, main_text):
            super(CustomConfDialog, self).__init__()
            self.setObjectName("Tribler")
            self.setWindowTitle("Tribler: Critical Error!")
            self.resize(500, 300)
            dlg = ConfirmationDialog(
                self, title, main_text, [("CLOSE", BUTTON_TYPE_NORMAL)]
            )
            dlg.show()
            dlg.button_clicked.connect(lambda: sys.exit(1))

    dialog = CustomConfDialog(title, main_text)
    dialog.show()
    app.exec_()
    sys.exit(1)


# Traceback (AssertionError)
Tuples differ: (2, ('127.0.0.1', [5, 4, 3, 2,... != (2, ('127.0.0.1', [5, 4, 3, 2,...

First differing element 2:
u'None'
''

- (2, ('127.0.0.1', [5, 4, 3, 2, 1]), u'None')
?                                     - ----

+ (2, ('127.0.0.1', [5, 4, 3, 2, 1]), '')
Stacktrace

Traceback (most recent call last):
File "c:\python27\lib\unittest\case.py", line 329, in run
testMethod()
File "C:\workspace\jenkins\workspace\GH_Tribler_PR_tests_win64\tribler\Tribler\Test\test_as_server.py", line 58, in check
result = fun(*argv, **kwargs)
File "C:\workspace\jenkins\workspace\GH_Tribler_PR_tests_win64\tribler\Tribler\Test\Core\Upgrade\test_config_upgrade_70_71.py", line 33, in test_read_test_libtribler_conf
self.assertEqual(result_config.get_anon_proxy_settings(), (2, ("127.0.0.1", [5, 4, 3, 2, 1]), ''))
File "c:\python27\lib\unittest\case.py", line 513, in assertEqual
assertion_func(first, second, msg=msg)
File "c:\python27\lib\unittest\case.py", line 753, in assertTupleEqual
self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
File "c:\python27\lib\unittest\case.py", line 724, in assertSequenceEqual
self.fail(msg)
File "c:\python27\lib\unittest\case.py", line 410, in fail
raise self.failureException(msg)
AssertionError: Tuples differ: (2, ('127.0.0.1', [5, 4, 3, 2,... != (2, ('127.0.0.1', [5, 4, 3, 2,...

First differing element 2:
u'None'
''

- (2, ('127.0.0.1', [5, 4, 3, 2, 1]), u'None')
?                                     - ----

+ (2, ('127.0.0.1', [5, 4, 3, 2, 1]), '')

# Fixed code
def error_and_exit(title, main_text):
    """
    Show a pop-up window and sys.exit() out of Python.

    :param title: the short error description
    :param main_text: the long error description
    """
    # NOTE: We don't want to load all of these imports normally.
    #       Otherwise we will have these unused GUI modules loaded in the main process.
    from Tkinter import Tk, Canvas, DISABLED, INSERT, Label, Text, WORD

    root = Tk()
    root.wm_title("Tribler: Critical Error!")
    root.wm_minsize(500, 300)
    root.wm_maxsize(500, 300)
    root.configure(background="#535252")

    Canvas(
        root,
        width=500,
        height=50,
        bd=0,
        highlightthickness=0,
        relief="ridge",
        background="#535252",
    ).pack()
    pane = Canvas(
        root,
        width=400,
        height=200,
        bd=0,
        highlightthickness=0,
        relief="ridge",
        background="#333333",
    )
    Canvas(
        pane,
        width=400,
        height=20,
        bd=0,
        highlightthickness=0,
        relief="ridge",
        background="#333333",
    ).pack()
    Label(
        pane,
        text=title,
        width=40,
        background="#333333",
        foreground="#fcffff",
        font=("Helvetica", 11),
    ).pack()
    Canvas(
        pane,
        width=400,
        height=20,
        bd=0,
        highlightthickness=0,
        relief="ridge",
        background="#333333",
    ).pack()

    main_text_label = Text(
        pane,
        width=45,
        height=6,
        bd=0,
        highlightthickness=0,
        relief="ridge",
        background="#333333",
        foreground="#b5b5b5",
        font=("Helvetica", 11),
        wrap=WORD,
    )
    main_text_label.tag_configure("center", justify="center")
    main_text_label.insert(INSERT, main_text)
    main_text_label.tag_add("center", "1.0", "end")
    main_text_label.config(state=DISABLED)
    main_text_label.pack()

    pane.pack()

    root.mainloop()