https://github.com/python/cpython/commit/44d1aebd9f228e34bc7d8d9bc3e145794dc4c6bc
commit: 44d1aebd9f228e34bc7d8d9bc3e145794dc4c6bc
branch: 3.14
author: Bartosz SÅ‚awecki <[email protected]>
committer: Eclips4 <[email protected]>
date: 2026-06-14T16:40:51Z
summary:

[3.14] gh-151390: Colorize `match +` and `match -` in the REPL (GH-151391) 
(#151477)

(cherry picked from commit a7007322c2a70b01e7c2a9e6b3f8f222d241c7d7)

files:
A Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst
M Lib/_pyrepl/utils.py
M Lib/test/test_pyrepl/test_utils.py

diff --git a/Lib/_pyrepl/utils.py b/Lib/_pyrepl/utils.py
index 06cddef851bb404..1a697ad61c8e896 100644
--- a/Lib/_pyrepl/utils.py
+++ b/Lib/_pyrepl/utils.py
@@ -242,7 +242,7 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
             None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
             TI(string="match"),
             TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
-            | TI(T.OP, string="(" | "*" | "[" | "{" | "~" | "...")
+            | TI(T.OP, string="(" | "*" | "-" | "+" | "[" | "{" | "~" | "...")
         ):
             return True
         case (
diff --git a/Lib/test/test_pyrepl/test_utils.py 
b/Lib/test/test_pyrepl/test_utils.py
index 656a1e441e0e473..b621071f1249c30 100644
--- a/Lib/test/test_pyrepl/test_utils.py
+++ b/Lib/test/test_pyrepl/test_utils.py
@@ -93,6 +93,22 @@ def test_gen_colors_keyword_highlighting(self):
             ("set", [("set", "builtin")]),
             ("list", [("list", "builtin")]),
             ("    \n dict", [("dict", "builtin")]),
+            (
+                "match +1",
+                [
+                    ("match", "soft_keyword"),
+                    ("+", "op"),
+                    ("1", "number"),
+                ],
+            ),
+            (
+                "match -1",
+                [
+                    ("match", "soft_keyword"),
+                    ("-", "op"),
+                    ("1", "number"),
+                ],
+            ),
         ]
         for code, expected_highlights in cases:
             with self.subTest(code=code):
diff --git 
a/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst 
b/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst
new file mode 100644
index 000000000000000..ff8de30599c6ad5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst
@@ -0,0 +1 @@
+Colorize ``match`` in the :term:`REPL` when followed by a unary ``+`` or ``-`` 
operator. Patch by Bartosz Sławecki.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to