File tree Expand file tree Collapse file tree 5 files changed +10
-9
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 5 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ async def test_lock(self):
39
39
40
40
with self .assertRaisesRegex (
41
41
TypeError ,
42
- "object Lock can't be used in 'await' expression "
42
+ "' Lock' object can't be awaited "
43
43
):
44
44
await lock
45
45
@@ -77,7 +77,7 @@ async def test_lock_by_with_statement(self):
77
77
self .assertFalse (lock .locked ())
78
78
with self .assertRaisesRegex (
79
79
TypeError ,
80
- r"object \w+ can't be used in 'await' expression "
80
+ r"' \w+' object can't be awaited "
81
81
):
82
82
with await lock :
83
83
pass
@@ -941,7 +941,7 @@ async def test_semaphore(self):
941
941
942
942
with self .assertRaisesRegex (
943
943
TypeError ,
944
- "object Semaphore can't be used in 'await' expression " ,
944
+ "' Semaphore' object can't be awaited " ,
945
945
):
946
946
await sem
947
947
@@ -1270,7 +1270,7 @@ async def test_barrier(self):
1270
1270
self .assertIn ("filling" , repr (barrier ))
1271
1271
with self .assertRaisesRegex (
1272
1272
TypeError ,
1273
- "object Barrier can't be used in 'await' expression " ,
1273
+ "' Barrier' object can't be awaited " ,
1274
1274
):
1275
1275
await barrier
1276
1276
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ async def test(lock):
77
77
self .assertFalse (lock .locked ())
78
78
with self .assertRaisesRegex (
79
79
TypeError ,
80
- "can't be used in 'await' expression "
80
+ "can't be awaited "
81
81
):
82
82
with await lock :
83
83
pass
Original file line number Diff line number Diff line change @@ -974,13 +974,13 @@ def test_await_1(self):
974
974
975
975
async def foo ():
976
976
await 1
977
- with self .assertRaisesRegex (TypeError , "object int can.t.*await " ):
977
+ with self .assertRaisesRegex (TypeError , "' int' object can.t be awaited " ):
978
978
run_async (foo ())
979
979
980
980
def test_await_2 (self ):
981
981
async def foo ():
982
982
await []
983
- with self .assertRaisesRegex (TypeError , "object list can.t.*await " ):
983
+ with self .assertRaisesRegex (TypeError , "' list' object can.t be awaited " ):
984
984
run_async (foo ())
985
985
986
986
def test_await_3 (self ):
@@ -1040,7 +1040,7 @@ class Awaitable:
1040
1040
async def foo (): return await Awaitable ()
1041
1041
1042
1042
with self .assertRaisesRegex (
1043
- TypeError , "object Awaitable can't be used in 'await' expression " ):
1043
+ TypeError , "' Awaitable' object can't be awaited " ):
1044
1044
1045
1045
run_async (foo ())
1046
1046
Original file line number Diff line number Diff line change
1
+ Changed the error message for awaiting something that can't be awaited from "object <type> can't be used in an await expression" to "'<type>' object can't be awaited".
Original file line number Diff line number Diff line change @@ -1047,7 +1047,7 @@ _PyCoro_GetAwaitableIter(PyObject *o)
1047
1047
}
1048
1048
1049
1049
PyErr_Format (PyExc_TypeError ,
1050
- "object %.100s can't be used in 'await' expression " ,
1050
+ "' %.100s' object can't be awaited " ,
1051
1051
ot -> tp_name );
1052
1052
return NULL ;
1053
1053
}
You can’t perform that action at this time.
0 commit comments