From 594413e8f05268bc0d448d37022c502af28e1244 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Fri, 30 Sep 2022 23:43:27 +0100 Subject: [PATCH] Use an explicit encoding when opening `os.devnul` Although slightly pointless, this avoids an `EncodingWarning` in Python 3.10 or greater when running under the `-X warn_default_encoding` flag. --- src/_pytest/capture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index bcfd3449f..6131a46df 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -381,7 +381,7 @@ class FDCaptureBinary: self.targetfd_save = os.dup(targetfd) if targetfd == 0: - self.tmpfile = open(os.devnull) + self.tmpfile = open(os.devnull, encoding="utf-8") self.syscapture = SysCapture(targetfd) else: self.tmpfile = EncodedFile(