diff --git a/src/_pytest/mark/legacy.py b/src/_pytest/mark/legacy.py
index <HASH>..<HASH> 100644
--- a/src/_pytest/mark/legacy.py
+++ b/src/_pytest/mark/legacy.py
@@ -106,5 +106,5 @@ def matchkeyword(colitem, keywordexpr):
             )
     try:
         return eval(keywordexpr, {}, mapping)
-    except SyntaxError:
+    except Exception:
         raise UsageError("Wrong expression passed to '-k': {}".format(keywordexpr))
Check invalid operations for -k

`KeywordMapping` returns a bool on lookup which when passed to eval
fail on certain operations such as index access and attribute access.
We catch all exceptions and raise a `UsageError`.