summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-05-20 07:32:32 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-05-20 07:38:29 +0200
commit3072e7338cfc63f2f81f34d02edc34dab3d9f365 (patch)
tree5ff31f923c1db2e3a61e094a5126593c4f17ceb8
parenta0096e30779fc1a15ed14371999c1b423aba6e5a (diff)
menuconfig: Fix bad regex crash on Python 3.4-
re.error.msg was added in Python 3.5. Show a generic error message when it isn't available.
-rwxr-xr-xmenuconfig.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/menuconfig.py b/menuconfig.py
index 9f6f28e..d81d891 100755
--- a/menuconfig.py
+++ b/menuconfig.py
@@ -1463,7 +1463,11 @@ def _jump_to_dialog():
except re.error as e:
# Bad regex. Remember the error message so we can show it.
- bad_re = e.msg
+ bad_re = "Bad regular expression"
+ # re.error.msg was added in Python 3.5
+ if hasattr(e, "msg"):
+ bad_re += ": " + e.msg
+
matches = []
# Reset scroll and jump to the top of the list of matches
@@ -1604,10 +1608,7 @@ def _draw_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,
else:
# bad_re holds the error message from the re.error exception on errors
- _safe_addstr(matches_win, 0, 0,
- "No matches"
- if bad_re is None else
- "Bad regular expression: " + bad_re)
+ _safe_addstr(matches_win, 0, 0, bad_re or "No matches")
matches_win.noutrefresh()