From 14f2420500d840ac3c8cd1af61c643cd101ca173 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 19 Feb 2015 22:45:37 +0100 Subject: [PATCH] Fix wrong parsing of faulthandler logs. --- qutebrowser/misc/crashdialog.py | 2 +- qutebrowser/test/misc/test_crashdialog.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index df5e39397..1cf5a75e8 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -60,7 +60,7 @@ def parse_fatal_stacktrace(text): # We got some invalid text. return ('', '') else: - return (m.group(1), m.group(2)) + return (m.group(1), m.group(3)) def get_fatal_crash_dialog(debug, data): diff --git a/qutebrowser/test/misc/test_crashdialog.py b/qutebrowser/test/misc/test_crashdialog.py index 6e9344a14..6c93833b1 100644 --- a/qutebrowser/test/misc/test_crashdialog.py +++ b/qutebrowser/test/misc/test_crashdialog.py @@ -40,6 +40,13 @@ Current thread 0x00007f09b538d700 (most recent call first): File "filename", line 88 in func """ +VALID_CRASH_TEXT_THREAD = """ +Fatal Python error: Segmentation fault +_ +Thread 0x00007fa135ac7700 (most recent call first): + File "", line 1 in testfunc +""" + INVALID_CRASH_TEXT = """ Hello world! """ @@ -56,6 +63,13 @@ class ParseFatalStacktraceTests(unittest.TestCase): self.assertEqual(typ, "Segmentation fault") self.assertEqual(func, 'testfunc') + def test_valid_text_thread(self): + """Test parse_fatal_stacktrace with a valid text #2.""" + text = VALID_CRASH_TEXT_THREAD.strip().replace('_', ' ') + typ, func = crashdialog.parse_fatal_stacktrace(text) + self.assertEqual(typ, "Segmentation fault") + self.assertEqual(func, 'testfunc') + def test_valid_text_empty(self): """Test parse_fatal_stacktrace with a valid text but empty function.""" text = VALID_CRASH_TEXT_EMPTY.strip().replace('_', ' ')