https://github.com/python/cpython/commit/3a648445337098abf22c7faa296389dab597797c
commit: 3a648445337098abf22c7faa296389dab597797c
branch: main
author: Olga Matoula <[email protected]>
committer: ambv <[email protected]>
date: 2025-07-19T15:15:49+02:00
summary:
gh-136801: Fix PyREPL syntax highlightning on match cases after multi-line case
(GH-136804)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-07-19-12-37-05.gh-issue-136801.XU_tF2.rst
M Lib/_pyrepl/utils.py
M Lib/test/test_pyrepl/test_reader.py
diff --git a/Lib/_pyrepl/utils.py b/Lib/_pyrepl/utils.py
index e04fbdc6c8a5c4..fd788c8429e15b 100644
--- a/Lib/_pyrepl/utils.py
+++ b/Lib/_pyrepl/utils.py
@@ -241,14 +241,14 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
return s in keyword_first_sets_match
return True
case (
- None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
+ None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) |
TI(string=":"),
TI(string="case"),
TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
| TI(T.OP, string="(" | "*" | "-" | "[" | "{")
):
return True
case (
- None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
+ None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) |
TI(string=":"),
TI(string="case"),
TI(T.NAME, string=s)
):
diff --git a/Lib/test/test_pyrepl/test_reader.py
b/Lib/test/test_pyrepl/test_reader.py
index 1f655264f1c00a..9a02dff7387563 100644
--- a/Lib/test/test_pyrepl/test_reader.py
+++ b/Lib/test/test_pyrepl/test_reader.py
@@ -375,7 +375,8 @@ def funct(case: str = sys.platform) -> None:
)
match case:
case "emscripten": print("on the web")
- case "ios" | "android": print("on the phone")
+ case "ios" | "android":
+ print("on the phone")
case _: print('arms around', match.group(1))
"""
)
@@ -393,7 +394,8 @@ def funct(case: str = sys.platform) -> None:
{o}){z}
{K}match{z} case{o}:{z}
{K}case{z} {s}"emscripten"{z}{o}:{z}
{b}print{z}{o}({z}{s}"on the web"{z}{o}){z}
- {K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z}
{b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
+ {K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z}
+ {b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
{K}case{z} {K}_{z}{o}:{z} {b}print{z}{o}({z}{s}'arms
around'{z}{o},{z} match{o}.{z}group{o}({z}{n}1{z}{o}){z}{o}){z}
"""
)
@@ -402,14 +404,14 @@ def funct(case: str = sys.platform) -> None:
reader, _ = handle_all_events(events)
self.assert_screen_equal(reader, code, clean=True)
self.assert_screen_equal(reader, expected_sync)
- self.assertEqual(reader.pos, 2**7 + 2**8)
- self.assertEqual(reader.cxy, (0, 14))
+ self.assertEqual(reader.pos, 396)
+ self.assertEqual(reader.cxy, (0, 15))
async_msg = "{k}async{z} ".format(**colors)
expected_async = expected.format(a=async_msg, **colors)
more_events = itertools.chain(
code_to_events(code),
- [Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 13,
+ [Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 14,
code_to_events("async "),
)
reader, _ = handle_all_events(more_events)
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2025-07-19-12-37-05.gh-issue-136801.XU_tF2.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-19-12-37-05.gh-issue-136801.XU_tF2.rst
new file mode 100644
index 00000000000000..5c0813b1a0abda
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-19-12-37-05.gh-issue-136801.XU_tF2.rst
@@ -0,0 +1 @@
+Fix PyREPL syntax highlightning on match cases after multi-line case.
Contributed by Olga Matoula.
_______________________________________________
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]