From 7f76c3ba1324860abe6cf6862d3fa3de6cb3150a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Sep 2014 16:58:38 +0200 Subject: [PATCH] safe_shlex_split: cleanup and don't do double-lexing --- qutebrowser/utils/utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 22835bf0d..ca7d77bac 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -123,7 +123,6 @@ def safe_shlex_split(s): We try 3 times so multiple errors can be fixed. """ - tokens = None orig_s = s for i in range(3): lexer = _get_lexer(s) @@ -139,11 +138,11 @@ def safe_shlex_split(s): "Lexer state is >{}< while parsing >{}< (attempted fixup: " ">{}<)".format(lexer.state, orig_s, s)) s += lexer.state - if tokens is None: - raise AssertionError("Gave up splitting >{}< after {} tries. " - "Attempted fixup: >{}<. This is a bug.".format( - orig_s, i, s)) - return tokens + else: + return tokens + # We should never arrive here. + raise AssertionError("Gave up splitting >{}< after {} tries. " + "Attempted fixup: >{}<.".format(orig_s, i, s)) def pastebin(text):