Skip to content
/ cpython Public
  • Rate limit · GitHub

    Access has been restricted

    You have triggered a rate limit.

    Please wait a few minutes before you try again;
    in some cases this may take up to an hour.

  • Notifications You must be signed in to change notification settings
  • Fork 31.3k
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-114091: Reword error message for unawaitable types #114090

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reword error message for unawaitable types.
"object $type can't be ..." -> "'$type' object can't be ..."
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

swfarnsworth committed Jan 15, 2024
commit f5cb1c61aadd33a5ab1bcb5d40489fd378248ac7
8 changes: 4 additions & 4 deletions Lib/test/test_asyncio/test_locks.py
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ async def test_lock(self):

with self.assertRaisesRegex(
TypeError,
"object Lock can't be used in 'await' expression"
"'Lock' object can't be used in 'await' expression"
):
await lock

@@ -77,7 +77,7 @@ async def test_lock_by_with_statement(self):
self.assertFalse(lock.locked())
with self.assertRaisesRegex(
TypeError,
r"object \w+ can't be used in 'await' expression"
r"'\w+' object can't be used in 'await' expression"
):
with await lock:
pass
@@ -849,7 +849,7 @@ async def test_semaphore(self):

with self.assertRaisesRegex(
TypeError,
"object Semaphore can't be used in 'await' expression",
"'Semaphore' object can't be used in 'await' expression",
):
await sem

@@ -1178,7 +1178,7 @@ async def test_barrier(self):
self.assertIn("filling", repr(barrier))
with self.assertRaisesRegex(
TypeError,
"object Barrier can't be used in 'await' expression",
"'Barrier' object can't be used in 'await' expression",
):
await barrier

2 changes: 1 addition & 1 deletion Lib/test/test_coroutines.py
Original file line number Diff line number Diff line change
@@ -1036,7 +1036,7 @@ class Awaitable:
async def foo(): return await Awaitable()

with self.assertRaisesRegex(
TypeError, "object Awaitable can't be used in 'await' expression"):
TypeError, "'Awaitable' object can't be used in 'await' expression"):

run_async(foo())

2 changes: 1 addition & 1 deletion Objects/genobject.c
Original file line number Diff line number Diff line change
@@ -1043,7 +1043,7 @@ _PyCoro_GetAwaitableIter(PyObject *o)
}

PyErr_Format(PyExc_TypeError,
"object %.100s can't be used in 'await' expression",
"'%.100s' object can't be used in 'await' expression",
ot->tp_name);
return NULL;
}