From 8288b52090c326f0e64f91f93ceb7d77c84b103a Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 28 Apr 2023 23:02:04 +0300 Subject: [PATCH] faulthandler: fix an EncodingWarning --- src/_pytest/faulthandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/faulthandler.py b/src/_pytest/faulthandler.py index b9c925582..f54e2024a 100644 --- a/src/_pytest/faulthandler.py +++ b/src/_pytest/faulthandler.py @@ -27,7 +27,7 @@ def pytest_configure(config: Config) -> None: import faulthandler stderr_fd_copy = os.dup(get_stderr_fileno()) - config.stash[fault_handler_stderr_key] = open(stderr_fd_copy, "w") + config.stash[fault_handler_stderr_key] = open(stderr_fd_copy, "w", encoding=sys.stderr.encoding) config.stash[fault_handler_originally_enabled_key] = faulthandler.is_enabled() faulthandler.enable(file=config.stash[fault_handler_stderr_key])