Skip to content

Commit ee006af

Browse files
authored
Align more error messages with CPython 3.14.5 (#7933)
* Align more error messages with CPython 3.14.5 * Align patches for `test_eof.py` * Unmark passing test * Fix more
1 parent de06fc0 commit ee006af

3 files changed

Lines changed: 116 additions & 72 deletions

File tree

Lib/test/test_eof.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import unittest
1010

1111
class EOFTestCase(unittest.TestCase):
12-
@unittest.expectedFailure # TODO: RUSTPYTHON
1312
def test_EOF_single_quote(self):
1413
expect = "unterminated string literal (detected at line 1) (<string>, line 1)"
1514
for quote in ("'", "\""):
@@ -19,7 +18,7 @@ def test_EOF_single_quote(self):
1918
self.assertEqual(str(cm.exception), expect)
2019
self.assertEqual(cm.exception.offset, 1)
2120

22-
@unittest.expectedFailure # TODO: RUSTPYTHON
21+
@unittest.expectedFailure # TODO: RUSTPYTHON
2322
def test_EOFS(self):
2423
expect = ("unterminated triple-quoted string literal (detected at line 3) (<string>, line 1)")
2524
with self.assertRaises(SyntaxError) as cm:
@@ -46,7 +45,7 @@ def test_EOFS(self):
4645
self.assertEqual(cm.exception.text, "ä = '''thîs is ")
4746
self.assertEqual(cm.exception.offset, 5)
4847

49-
@unittest.expectedFailure # TODO: RUSTPYTHON
48+
@unittest.expectedFailure # TODO: RUSTPYTHON
5049
@force_not_colorized
5150
def test_EOFS_with_file(self):
5251
expect = ("(<string>, line 1)")
@@ -87,15 +86,15 @@ def test_EOFS_with_file(self):
8786
' ^',
8887
'SyntaxError: unterminated triple-quoted string literal (detected at line 4)'])
8988

90-
@unittest.expectedFailure # TODO: RUSTPYTHON
89+
@unittest.expectedFailure # TODO: RUSTPYTHON
9190
@warnings_helper.ignore_warnings(category=SyntaxWarning)
9291
def test_eof_with_line_continuation(self):
9392
expect = "unexpected EOF while parsing (<string>, line 1)"
9493
with self.assertRaises(SyntaxError) as cm:
9594
compile('"\\Xhh" \\', '<string>', 'exec')
9695
self.assertEqual(str(cm.exception), expect)
9796

98-
@unittest.expectedFailure # TODO: RUSTPYTHON
97+
@unittest.expectedFailure # TODO: RUSTPYTHON
9998
def test_line_continuation_EOF(self):
10099
"""A continuation at the end of input must be an error; bpo2180."""
101100
expect = 'unexpected EOF while parsing (<string>, line 1)'
@@ -128,7 +127,7 @@ def test_line_continuation_EOF(self):
128127
exec('\\')
129128
self.assertEqual(str(cm.exception), expect)
130129

131-
@unittest.expectedFailure # TODO: RUSTPYTHON
130+
@unittest.expectedFailure # TODO: RUSTPYTHON
132131
@unittest.skipIf(not sys.executable, "sys.executable required")
133132
@force_not_colorized
134133
def test_line_continuation_EOF_from_file_bpo2180(self):

Lib/test/test_syntax.py

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@
156156
Traceback (most recent call last):
157157
SyntaxError: cannot assign to conditional expression
158158
159-
>>> a = 42 if True # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
159+
>>> a = 42 if True
160160
Traceback (most recent call last):
161161
SyntaxError: expected 'else' after 'if' expression
162162
163-
>>> a = (42 if True) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
163+
>>> a = (42 if True)
164164
Traceback (most recent call last):
165165
SyntaxError: expected 'else' after 'if' expression
166166
167-
>>> a = [1, 42 if True, 4] # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
167+
>>> a = [1, 42 if True, 4]
168168
Traceback (most recent call last):
169169
SyntaxError: expected 'else' after 'if' expression
170170
@@ -275,7 +275,7 @@
275275
Traceback (most recent call last):
276276
SyntaxError: cannot assign to function call
277277
278-
>>> with a as b # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
278+
>>> with a as b
279279
Traceback (most recent call last):
280280
SyntaxError: expected ':'
281281
@@ -478,47 +478,47 @@
478478
Traceback (most recent call last):
479479
SyntaxError: var-keyword argument cannot have default value
480480
481-
>>> def foo(a,*a, b, **c, d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
481+
>>> def foo(a,*a, b, **c, d):
482482
... pass
483483
Traceback (most recent call last):
484484
SyntaxError: arguments cannot follow var-keyword argument
485485
486-
>>> def foo(a,*a, b, **c, d=4): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
486+
>>> def foo(a,*a, b, **c, d=4):
487487
... pass
488488
Traceback (most recent call last):
489489
SyntaxError: arguments cannot follow var-keyword argument
490490
491-
>>> def foo(a,*a, b, **c, *d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
491+
>>> def foo(a,*a, b, **c, *d):
492492
... pass
493493
Traceback (most recent call last):
494494
SyntaxError: arguments cannot follow var-keyword argument
495495
496-
>>> def foo(a,*a, b, **c, **d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
496+
>>> def foo(a,*a, b, **c, **d):
497497
... pass
498498
Traceback (most recent call last):
499499
SyntaxError: arguments cannot follow var-keyword argument
500500
501-
>>> def foo(a=1,/,**b,/,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
501+
>>> def foo(a=1,/,**b,/,c):
502502
... pass
503503
Traceback (most recent call last):
504504
SyntaxError: arguments cannot follow var-keyword argument
505505
506-
>>> def foo(*b,*d): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
506+
>>> def foo(*b,*d):
507507
... pass
508508
Traceback (most recent call last):
509509
SyntaxError: * argument may appear only once
510510
511-
>>> def foo(a,*b,c,*d,*e,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
511+
>>> def foo(a,*b,c,*d,*e,c):
512512
... pass
513513
Traceback (most recent call last):
514514
SyntaxError: * argument may appear only once
515515
516-
>>> def foo(a,b,/,c,*b,c,*d,*e,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
516+
>>> def foo(a,b,/,c,*b,c,*d,*e,c):
517517
... pass
518518
Traceback (most recent call last):
519519
SyntaxError: * argument may appear only once
520520
521-
>>> def foo(a,b,/,c,*b,c,*d,**e): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
521+
>>> def foo(a,b,/,c,*b,c,*d,**e):
522522
... pass
523523
Traceback (most recent call last):
524524
SyntaxError: * argument may appear only once
@@ -583,39 +583,39 @@
583583
Traceback (most recent call last):
584584
SyntaxError: var-keyword argument cannot have default value
585585
586-
>>> lambda a, *a, b, **c, d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
586+
>>> lambda a, *a, b, **c, d: None
587587
Traceback (most recent call last):
588588
SyntaxError: arguments cannot follow var-keyword argument
589589
590-
>>> lambda a,*a, b, **c, d=4: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
590+
>>> lambda a,*a, b, **c, d=4: None
591591
Traceback (most recent call last):
592592
SyntaxError: arguments cannot follow var-keyword argument
593593
594-
>>> lambda a,*a, b, **c, *d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
594+
>>> lambda a,*a, b, **c, *d: None
595595
Traceback (most recent call last):
596596
SyntaxError: arguments cannot follow var-keyword argument
597597
598-
>>> lambda a,*a, b, **c, **d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
598+
>>> lambda a,*a, b, **c, **d: None
599599
Traceback (most recent call last):
600600
SyntaxError: arguments cannot follow var-keyword argument
601601
602-
>>> lambda a=1,/,**b,/,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
602+
>>> lambda a=1,/,**b,/,c: None
603603
Traceback (most recent call last):
604604
SyntaxError: arguments cannot follow var-keyword argument
605605
606-
>>> lambda *b,*d: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
606+
>>> lambda *b,*d: None
607607
Traceback (most recent call last):
608608
SyntaxError: * argument may appear only once
609609
610-
>>> lambda a,*b,c,*d,*e,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
610+
>>> lambda a,*b,c,*d,*e,c: None
611611
Traceback (most recent call last):
612612
SyntaxError: * argument may appear only once
613613
614-
>>> lambda a,b,/,c,*b,c,*d,*e,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
614+
>>> lambda a,b,/,c,*b,c,*d,*e,c: None
615615
Traceback (most recent call last):
616616
SyntaxError: * argument may appear only once
617617
618-
>>> lambda a,b,/,c,*b,c,*d,**e: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
618+
>>> lambda a,b,/,c,*b,c,*d,**e: None
619619
Traceback (most recent call last):
620620
SyntaxError: * argument may appear only once
621621
@@ -1093,27 +1093,27 @@
10931093
10941094
Missing ':' before suites:
10951095
1096-
>>> def f() # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1096+
>>> def f()
10971097
... pass
10981098
Traceback (most recent call last):
10991099
SyntaxError: expected ':'
11001100
1101-
>>> def f[T]() # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1101+
>>> def f[T]()
11021102
... pass
11031103
Traceback (most recent call last):
11041104
SyntaxError: expected ':'
11051105
1106-
>>> class A # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1106+
>>> class A
11071107
... pass
11081108
Traceback (most recent call last):
11091109
SyntaxError: expected ':'
11101110
1111-
>>> class A[T] # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1111+
>>> class A[T]
11121112
... pass
11131113
Traceback (most recent call last):
11141114
SyntaxError: expected ':'
11151115
1116-
>>> class A[T]() # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1116+
>>> class A[T]()
11171117
... pass
11181118
Traceback (most recent call last):
11191119
SyntaxError: expected ':'
@@ -1123,7 +1123,7 @@
11231123
Traceback (most recent call last):
11241124
SyntaxError: invalid syntax
11251125
1126-
>>> if 1 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1126+
>>> if 1
11271127
... pass
11281128
... elif 1:
11291129
... pass
@@ -1132,7 +1132,7 @@
11321132
Traceback (most recent call last):
11331133
SyntaxError: expected ':'
11341134
1135-
>>> if 1: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1135+
>>> if 1:
11361136
... pass
11371137
... elif 1
11381138
... pass
@@ -1141,7 +1141,7 @@
11411141
Traceback (most recent call last):
11421142
SyntaxError: expected ':'
11431143
1144-
>>> if 1: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1144+
>>> if 1:
11451145
... pass
11461146
... elif 1:
11471147
... pass
@@ -1150,7 +1150,7 @@
11501150
Traceback (most recent call last):
11511151
SyntaxError: expected ':'
11521152
1153-
>>> for x in range(10) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1153+
>>> for x in range(10)
11541154
... pass
11551155
Traceback (most recent call last):
11561156
SyntaxError: expected ':'
@@ -1160,47 +1160,47 @@
11601160
Traceback (most recent call last):
11611161
SyntaxError: invalid syntax
11621162
1163-
>>> while True # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1163+
>>> while True
11641164
... pass
11651165
Traceback (most recent call last):
11661166
SyntaxError: expected ':'
11671167
1168-
>>> with blech as something # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1168+
>>> with blech as something
11691169
... pass
11701170
Traceback (most recent call last):
11711171
SyntaxError: expected ':'
11721172
1173-
>>> with blech # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1173+
>>> with blech
11741174
... pass
11751175
Traceback (most recent call last):
11761176
SyntaxError: expected ':'
11771177
1178-
>>> with blech, block as something # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1178+
>>> with blech, block as something
11791179
... pass
11801180
Traceback (most recent call last):
11811181
SyntaxError: expected ':'
11821182
1183-
>>> with blech, block as something, bluch # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1183+
>>> with blech, block as something, bluch
11841184
... pass
11851185
Traceback (most recent call last):
11861186
SyntaxError: expected ':'
11871187
1188-
>>> with (blech as something) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1188+
>>> with (blech as something)
11891189
... pass
11901190
Traceback (most recent call last):
11911191
SyntaxError: expected ':'
11921192
1193-
>>> with (blech) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1193+
>>> with (blech)
11941194
... pass
11951195
Traceback (most recent call last):
11961196
SyntaxError: expected ':'
11971197
1198-
>>> with (blech, block as something) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1198+
>>> with (blech, block as something)
11991199
... pass
12001200
Traceback (most recent call last):
12011201
SyntaxError: expected ':'
12021202
1203-
>>> with (blech, block as something, bluch) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1203+
>>> with (blech, block as something, bluch)
12041204
... pass
12051205
Traceback (most recent call last):
12061206
SyntaxError: expected ':'
@@ -1210,19 +1210,19 @@
12101210
Traceback (most recent call last):
12111211
SyntaxError: invalid syntax. Did you mean 'and'?
12121212
1213-
>>> try # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1213+
>>> try
12141214
... pass
12151215
Traceback (most recent call last):
12161216
SyntaxError: expected ':'
12171217
1218-
>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1218+
>>> try:
12191219
... pass
12201220
... except
12211221
... pass
12221222
Traceback (most recent call last):
12231223
SyntaxError: expected ':'
12241224
1225-
>>> match x # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1225+
>>> match x
12261226
... case list():
12271227
... pass
12281228
Traceback (most recent call last):
@@ -1234,13 +1234,13 @@
12341234
Traceback (most recent call last):
12351235
SyntaxError: invalid syntax
12361236
1237-
>>> match x: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1237+
>>> match x:
12381238
... case list()
12391239
... pass
12401240
Traceback (most recent call last):
12411241
SyntaxError: expected ':'
12421242
1243-
>>> match x: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1243+
>>> match x:
12441244
... case [y] if y > 0
12451245
... pass
12461246
Traceback (most recent call last):
@@ -1287,27 +1287,27 @@
12871287
12881288
Missing parens after function definition
12891289
1290-
>>> def f: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1290+
>>> def f:
12911291
Traceback (most recent call last):
12921292
SyntaxError: expected '('
12931293
1294-
>>> async def f: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1294+
>>> async def f:
12951295
Traceback (most recent call last):
12961296
SyntaxError: expected '('
12971297
1298-
>>> def f -> int: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1298+
>>> def f -> int:
12991299
Traceback (most recent call last):
13001300
SyntaxError: expected '('
13011301
1302-
>>> async def f -> int: # type: int # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1302+
>>> async def f -> int: # type: int
13031303
Traceback (most recent call last):
13041304
SyntaxError: expected '('
13051305
1306-
>>> async def f[T]: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1306+
>>> async def f[T]:
13071307
Traceback (most recent call last):
13081308
SyntaxError: expected '('
13091309
1310-
>>> def f[T] -> str: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1310+
>>> def f[T] -> str:
13111311
Traceback (most recent call last):
13121312
SyntaxError: expected '('
13131313
@@ -3092,7 +3092,6 @@ async def bug():
30923092
with self.subTest(f"out of range: {n=}"):
30933093
self._check_error(get_code(n), "too many statically nested blocks")
30943094

3095-
@unittest.expectedFailure # TODO: RUSTPYTHON
30963095
def test_barry_as_flufl_with_syntax_errors(self):
30973096
# The "barry_as_flufl" rule can produce some "bugs-at-a-distance" if
30983097
# is reading the wrong token in the presence of syntax errors later

0 commit comments

Comments
 (0)