extmod/asyncio: Emit errors to stderr, not stdout.

Sometimes these are different file descriptors, not to mention the Unix
port, so use stderr to distinguish these error messages.

CPython prints to stdout, but it does it via a call to the logging module.
We don't want to introduce a dependency on logging, so printing to stderr
is a good alternative.  One can override default_exception_handler() if
needed.
pull/12639/head
Matthias Urlichs 2023-10-06 21:03:24 +02:00 zatwierdzone przez Damien George
rodzic 05cb1406ad
commit 5f0bd33b73
1 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -272,9 +272,9 @@ class Loop:
return Loop._exc_handler
def default_exception_handler(loop, context):
print(context["message"])
print("future:", context["future"], "coro=", context["future"].coro)
sys.print_exception(context["exception"])
print(context["message"], file=sys.stderr)
print("future:", context["future"], "coro=", context["future"].coro, file=sys.stderr)
sys.print_exception(context["exception"], sys.stderr)
def call_exception_handler(context):
(Loop._exc_handler or Loop.default_exception_handler)(Loop, context)