]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43823: Fix location of one of the errors for invalid dictionary literals (GH...
authorPablo Galindo <Pablogsal@gmail.com>
Thu, 15 Apr 2021 23:45:42 +0000 (00:45 +0100)
committerGitHub <noreply@github.com>
Thu, 15 Apr 2021 23:45:42 +0000 (00:45 +0100)
Grammar/python.gram
Parser/parser.c

index e5baac36636751eea3f4694e3f16724b9315d52b..d91e887e04dc0085480a21e3e12e8b95372e6e4f 100644 (file)
@@ -899,6 +899,7 @@ invalid_double_starred_kvpairs:
     | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use a starred expression in a dictionary value") }
     | expression a=':' &('}'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
 invalid_kvpair:
-    | a=expression !(':') { RAISE_SYNTAX_ERROR("':' expected after dictionary key") }
+    | a=expression !(':') {
+        RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, a->lineno, a->end_col_offset - 1, "':' expected after dictionary key") }
     | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use a starred expression in a dictionary value") }
     | expression a=':' {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
index 2f7a71a5418e6478b811725bba1ec19b1a8a259d..e47093e1dca7ddddb865af3231dfa0505b64445f 100644 (file)
@@ -19379,7 +19379,7 @@ invalid_kvpair_rule(Parser *p)
         )
         {
             D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !(':')"));
-            _res = RAISE_SYNTAX_ERROR ( "':' expected after dictionary key" );
+            _res = RAISE_ERROR_KNOWN_LOCATION ( p , PyExc_SyntaxError , a -> lineno , a -> end_col_offset - 1 , "':' expected after dictionary key" );
             if (_res == NULL && PyErr_Occurred()) {
                 p->error_indicator = 1;
                 D(p->level--);