summaryrefslogtreecommitdiff
path: root/Cython
diff options
context:
space:
mode:
authorda-woods <dw-git@d-woods.co.uk>2023-04-28 10:36:56 +0100
committerGitHub <noreply@github.com>2023-04-28 11:36:56 +0200
commitcdce132997b60ace744da88572ee457e3a9444de (patch)
treef2bcaddbb4ed574c5163de9b35d209d9dc3a3aea /Cython
parent31d847ea1e64714dd75017c68f70aedc566eccb9 (diff)
downloadcython-cdce132997b60ace744da88572ee457e3a9444de.tar.gz
Fix parsing of bracketed then called context managers (GH-5404)
Require the bracketed multiple context managers to be followed by a colon, so that the bracketed called context manager is identified as regular parentheses in old-style syntax. Fixes https://github.com/cython/cython/issues/5403
Diffstat (limited to 'Cython')
-rw-r--r--Cython/Compiler/Parsing.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py
index 7c7b7f8a8..a796c865a 100644
--- a/Cython/Compiler/Parsing.py
+++ b/Cython/Compiler/Parsing.py
@@ -2141,6 +2141,10 @@ def p_with_items(s, is_async=False):
s.next()
items = p_with_items_list(s, is_async)
s.expect(")")
+ if s.sy != ":":
+ # Fail - the message doesn't matter because we'll try the
+ # non-bracket version so it'll never be shown
+ s.error("")
brackets_succeeded = not errors
if not brackets_succeeded:
# try the non-bracket version