Skip to content

Commit 4f6ff49

Browse files
committed
Fix traceback, syntax errors, and exception handling
1 parent c32a56b commit 4f6ff49

24 files changed

Lines changed: 409 additions & 164 deletions

‎Lib/test/test_asyncio/test_tasks.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,11 @@ async def coro():
29462946
def test_log_destroyed_pending_task(self):
29472947
return super().test_log_destroyed_pending_task()
29482948

2949+
# TODO: RUSTPYTHON; exception stack not preserved across coroutine switching
2950+
@unittest.expectedFailure
2951+
def test_exception_chaining_after_await(self):
2952+
return super().test_exception_chaining_after_await()
2953+
29492954

29502955
@unittest.skipUnless(hasattr(futures, '_CFuture') and
29512956
hasattr(tasks, '_CTask'),
@@ -2962,6 +2967,11 @@ class CTask_CFuture_SubclassTests(BaseTaskTests, test_utils.TestCase):
29622967
def test_log_destroyed_pending_task(self):
29632968
return super().test_log_destroyed_pending_task()
29642969

2970+
# TODO: RUSTPYTHON; exception stack not preserved across coroutine switching
2971+
@unittest.expectedFailure
2972+
def test_exception_chaining_after_await(self):
2973+
return super().test_exception_chaining_after_await()
2974+
29652975

29662976
@unittest.skipUnless(hasattr(tasks, '_CTask'),
29672977
'requires the C _asyncio module')
@@ -2977,6 +2987,11 @@ class CTaskSubclass_PyFuture_Tests(BaseTaskTests, test_utils.TestCase):
29772987
def test_log_destroyed_pending_task(self):
29782988
return super().test_log_destroyed_pending_task()
29792989

2990+
# TODO: RUSTPYTHON; exception stack not preserved across coroutine switching
2991+
@unittest.expectedFailure
2992+
def test_exception_chaining_after_await(self):
2993+
return super().test_exception_chaining_after_await()
2994+
29802995

29812996
@unittest.skipUnless(hasattr(futures, '_CFuture'),
29822997
'requires the C _asyncio module')
@@ -3006,6 +3021,11 @@ class CTask_PyFuture_Tests(BaseTaskTests, test_utils.TestCase):
30063021
def test_log_destroyed_pending_task(self):
30073022
return super().test_log_destroyed_pending_task()
30083023

3024+
# TODO: RUSTPYTHON; exception stack not preserved across coroutine switching
3025+
@unittest.expectedFailure
3026+
def test_exception_chaining_after_await(self):
3027+
return super().test_exception_chaining_after_await()
3028+
30093029

30103030
@unittest.skipUnless(hasattr(futures, '_CFuture'),
30113031
'requires the C _asyncio module')

‎Lib/test/test_cmd_line_script.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,6 @@ def test_dash_m_main_traceback(self):
548548
self.assertIn(b'Exception in __main__ module', err)
549549
self.assertIn(b'Traceback', err)
550550

551-
# TODO: RUSTPYTHON
552-
@unittest.expectedFailure
553551
def test_pep_409_verbiage(self):
554552
# Make sure PEP 409 syntax properly suppresses
555553
# the context of an exception

‎Lib/test/test_code_module.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def test_console_stderr(self):
9191
else:
9292
raise AssertionError("no console stdout")
9393

94-
@unittest.expectedFailure # TODO: RUSTPYTHON; + 'SyntaxError: invalid syntax']
9594
def test_syntax_error(self):
9695
self.infunc.side_effect = ["def f():",
9796
" x = ?",
@@ -166,7 +165,6 @@ def test_sysexcepthook(self):
166165
' File "<console>", line 2, in f\n',
167166
'ValueError: BOOM!\n'])
168167

169-
@unittest.expectedFailure # TODO: RUSTPYTHON; + 'SyntaxError: invalid syntax\n']
170168
def test_sysexcepthook_syntax_error(self):
171169
self.infunc.side_effect = ["def f():",
172170
" x = ?",
@@ -285,7 +283,6 @@ def test_exit_msg(self):
285283
self.assertEqual(err_msg, ['write', (expected,), {}])
286284

287285

288-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: '\nAttributeError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "<console>", line 1, in <module>\nValueError\n' not found in 'Python <MagicMock name=\'sys.version\' id=\'94615517503920\'> on <MagicMock name=\'sys.platform\' id=\'94615517656384\'>\nType "help", "copyright", "credits" or "license" for more information.\n(InteractiveConsole)\nAttributeError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "<console>", line 1, in <module>\nValueError: \n\nnow exiting InteractiveConsole...\n'
289286
def test_cause_tb(self):
290287
self.infunc.side_effect = ["raise ValueError('') from AttributeError",
291288
EOFError('Finished')]

‎Lib/test/test_contextlib.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,6 @@ def __exit__(self, *exc_details):
924924
self.assertIsInstance(inner_exc, ValueError)
925925
self.assertIsInstance(inner_exc.__context__, ZeroDivisionError)
926926

927-
# TODO: RUSTPYTHON
928-
@unittest.expectedFailure
929927
def test_exit_exception_chaining(self):
930928
# Ensure exception chaining matches the reference behaviour
931929
def raise_exc(exc):
@@ -957,8 +955,6 @@ def suppress_exc(*exc_details):
957955
self.assertIsInstance(inner_exc, ValueError)
958956
self.assertIsInstance(inner_exc.__context__, ZeroDivisionError)
959957

960-
# TODO: RUSTPYTHON
961-
@unittest.expectedFailure
962958
def test_exit_exception_explicit_none_context(self):
963959
# Ensure ExitStack chaining matches actual nested `with` statements
964960
# regarding explicit __context__ = None.
@@ -1053,8 +1049,6 @@ def gets_the_context_right(exc):
10531049
self.assertIsNone(
10541050
exc.__context__.__context__.__context__.__context__)
10551051

1056-
# TODO: RUSTPYTHON
1057-
@unittest.expectedFailure
10581052
def test_exit_exception_with_existing_context(self):
10591053
# Addresses a lack of test coverage discovered after checking in a
10601054
# fix for issue 20317 that still contained debugging code.

‎Lib/test/test_contextlib_async.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@ async def __aenter__(self):
650650
await stack.enter_async_context(LacksExit())
651651
self.assertFalse(stack._exit_callbacks)
652652

653-
@unittest.expectedFailure # TODO: RUSTPYTHON
654653
async def test_async_exit_exception_chaining(self):
655654
# Ensure exception chaining matches the reference behaviour
656655
async def raise_exc(exc):
@@ -682,7 +681,6 @@ async def suppress_exc(*exc_details):
682681
self.assertIsInstance(inner_exc, ValueError)
683682
self.assertIsInstance(inner_exc.__context__, ZeroDivisionError)
684683

685-
@unittest.expectedFailure # TODO: RUSTPYTHON
686684
async def test_async_exit_exception_explicit_none_context(self):
687685
# Ensure AsyncExitStack chaining matches actual nested `with` statements
688686
# regarding explicit __context__ = None.

‎Lib/test/test_exceptions.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,6 @@ def __del__(self):
17451745
f"deallocator {obj_repr}")
17461746
self.assertIsNotNone(cm.unraisable.exc_traceback)
17471747

1748-
@unittest.expectedFailure # TODO: RUSTPYTHON
17491748
def test_unhandled(self):
17501749
# Check for sensible reporting of unhandled exceptions
17511750
for exc_type in (ValueError, BrokenStrException):
@@ -2283,7 +2282,6 @@ def test_multiline_not_highlighted(self):
22832282
class SyntaxErrorTests(unittest.TestCase):
22842283
maxDiff = None
22852284

2286-
@unittest.expectedFailure # TODO: RUSTPYTHON
22872285
@force_not_colorized
22882286
def test_range_of_offsets(self):
22892287
cases = [

‎Lib/test/test_future_stmt/test_future.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ def test_unicode_literals_exec(self):
188188
exec("from __future__ import unicode_literals; x = ''", {}, scope)
189189
self.assertIsInstance(scope["x"], str)
190190

191+
# TODO: RUSTPYTHON; barry_as_FLUFL (<> operator) not supported
192+
@unittest.expectedFailure
191193
def test_syntactical_future_repl(self):
192194
p = spawn_python('-i')
193195
p.stdin.write(b"from __future__ import barry_as_FLUFL\n")

‎Lib/test/test_grammar.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ def test_ellipsis(self):
221221
self.assertTrue(x is Ellipsis)
222222
self.assertRaises(SyntaxError, eval, ".. .")
223223

224-
@unittest.expectedFailure # TODO: RUSTPYTHON
225224
def test_eof_error(self):
226225
samples = ("def foo(", "\ndef foo(", "def foo(\n")
227226
for s in samples:

‎Lib/test/test_inspect/test_inspect.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,6 @@ def test_stack(self):
568568
self.assertIn('inspect.stack()', record.code_context[0])
569569
self.assertEqual(record.index, 0)
570570

571-
@unittest.expectedFailure # TODO: RUSTPYTHON
572571
def test_trace(self):
573572
self.assertEqual(len(git.tr), 3)
574573
frame1, frame2, frame3, = git.tr

‎Lib/test/test_named_expressions.py‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,24 @@ def test_named_expression_invalid_06(self):
4444
with self.assertRaisesRegex(SyntaxError, "cannot use assignment expressions with tuple"):
4545
exec(code, {}, {})
4646

47-
# TODO: RUSTPYTHON: wrong error message
48-
@unittest.expectedFailure
4947
def test_named_expression_invalid_07(self):
5048
code = """def spam(a = b := 42): pass"""
5149

5250
with self.assertRaisesRegex(SyntaxError, "invalid syntax"):
5351
exec(code, {}, {})
5452

55-
# TODO: RUSTPYTHON: wrong error message
56-
@unittest.expectedFailure
5753
def test_named_expression_invalid_08(self):
5854
code = """def spam(a: b := 42 = 5): pass"""
5955

6056
with self.assertRaisesRegex(SyntaxError, "invalid syntax"):
6157
exec(code, {}, {})
6258

63-
# TODO: RUSTPYTHON: wrong error message
64-
@unittest.expectedFailure
6559
def test_named_expression_invalid_09(self):
6660
code = """spam(a=b := 'c')"""
6761

6862
with self.assertRaisesRegex(SyntaxError, "invalid syntax"):
6963
exec(code, {}, {})
7064

71-
# TODO: RUSTPYTHON: wrong error message
72-
@unittest.expectedFailure
7365
def test_named_expression_invalid_10(self):
7466
code = """spam(x = y := f(x))"""
7567

@@ -103,8 +95,6 @@ def test_named_expression_invalid_13(self):
10395
"positional argument follows keyword argument"):
10496
exec(code, {}, {})
10597

106-
# TODO: RUSTPYTHON: wrong error message
107-
@unittest.expectedFailure
10898
def test_named_expression_invalid_14(self):
10999
code = """(x := lambda: y := 1)"""
110100

@@ -120,8 +110,6 @@ def test_named_expression_invalid_15(self):
120110
"cannot use assignment expressions with lambda"):
121111
exec(code, {}, {})
122112

123-
# TODO: RUSTPYTHON: wrong error message
124-
@unittest.expectedFailure
125113
def test_named_expression_invalid_16(self):
126114
code = "[i + 1 for i in i := [1,2]]"
127115

0 commit comments

Comments
 (0)