Skip to content

Commit 594413e

Browse files
authored
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.
1 parent 59b8ec3 commit 594413e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/_pytest/capture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def __init__(self, targetfd: int) -> None:
381381
self.targetfd_save = os.dup(targetfd)
382382

383383
if targetfd == 0:
384-
self.tmpfile = open(os.devnull)
384+
self.tmpfile = open(os.devnull, encoding="utf-8")
385385
self.syscapture = SysCapture(targetfd)
386386
else:
387387
self.tmpfile = EncodedFile(

0 commit comments

Comments
 (0)