8000 bpo-32591: _PyErr_WarnUnawaitedCoroutine() sets source by vstinner · Pull Request #19247 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-32591: _PyErr_WarnUnawaitedCoroutine() sets source #19247

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

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Changes from all commits
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
8000
Diff view
23 changes: 20 additions & 3 deletions Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,23 @@ PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level,
return res;
}

static int
_PyErr_WarnFormat(PyObject *source, PyObject *category, Py_ssize_t stack_level,
const char *format, ...)
{
int res;
va_list vargs;

#ifdef HAVE_STDARG_PROTOTYPES
va_start(vargs, format);
#else
va_start(vargs);
#endif
res = _PyErr_WarnFormatV(source, category, stack_level, format, vargs);
va_end(vargs);
return res;
}

int
PyErr_ResourceWarning(PyObject *source, Py_ssize_t stack_level,
const char *format, ...)
Expand Down Expand Up @@ -1297,9 +1314,9 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro)
PyErr_WriteUnraisable(coro);
}
if (!warned) {
if (PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
"coroutine '%.50S' was never awaited",
((PyCoroObject *)coro)->cr_qualname) < 0)
if (_PyErr_WarnFormat(coro, PyExc_RuntimeWarning, 1,
"coroutine '%S' was never awaited",
((PyCoroObject *)coro)->cr_qualname) < 0)
{
PyErr_WriteUnraisable(coro);
}
Expand Down
0