Skip to content

Commit ad09d80

Browse files
committed
NotImplementedError -> RuntimeError
1 parent 4b7affb commit ad09d80

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Lib/asyncio/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ def _repr_info(self):
115115
return base_tasks._task_repr_info(self)
116116

117117
def set_result(self, result):
118-
raise NotImplementedError
118+
raise RuntimeError('Tasks do not support set_result operation')
119119

120120
def set_exception(self, exception):
121-
raise NotImplementedError
121+
raise RuntimeError('Tasks do not support set_exception operation')
122122

123123
def get_stack(self, *, limit=None):
124124
"""Return the list of stack frames for this task's coroutine.

Lib/test/test_asyncio/test_tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,10 +1340,10 @@ def notmuch():
13401340
gen = notmuch()
13411341
task = self.new_task(self.loop, gen)
13421342

1343-
with self.assertRaises(NotImplementedError):
1343+
with self.assertRaisesRegex(RuntimeError, 'not support set_result'):
13441344
task.set_result('ok')
13451345

1346-
with self.assertRaises(NotImplementedError):
1346+
with self.assertRaisesRegex(RuntimeError, 'not support set_exception'):
13471347
task.set_exception(ValueError())
13481348

13491349
self.assertEqual(

Modules/_asynciomodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,8 @@ static PyObject *
22432243
_asyncio_Task_set_result(TaskObj *self, PyObject *result)
22442244
/*[clinic end generated code: output=1dcae308bfcba318 input=9d1a00c07be41bab]*/
22452245
{
2246-
PyErr_SetNone(PyExc_NotImplementedError);
2246+
PyErr_SetString(PyExc_RuntimeError,
2247+
"Tasks do not support set_result operation");
22472248
return NULL;
22482249
}
22492250

@@ -2258,7 +2259,8 @@ static PyObject *
22582259
_asyncio_Task_set_exception(TaskObj *self, PyObject *exception)
22592260
/*[clinic end generated code: output=bc377fc28067303d input=9a8f65c83dcf893a]*/
22602261
{
2261-
PyErr_SetNone(PyExc_NotImplementedError);
2262+
PyErr_SetString(PyExc_RuntimeError,
2263+
"Tasks do not support set_exception operation");
22622264
return NULL;
22632265
}
22642266

0 commit comments

Comments
 (0)