Skip to content

Commit 384d54e

Browse files
authored
Merge pull request #10955 from pytest-dev/backport-10954-to-7.3.x
[7.3.x] Fix couple of EncodingWarnings
2 parents c403dc5 + 2ae187e commit 384d54e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/_pytest/_py/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def ensure(self, *args, **kwargs):
953953
else:
954954
p.dirpath()._ensuredirs()
955955
if not p.check(file=1):
956-
p.open("w").close()
956+
p.open("wb").close()
957957
return p
958958

959959
@overload

src/_pytest/faulthandler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def pytest_configure(config: Config) -> None:
2727
import faulthandler
2828

2929
stderr_fd_copy = os.dup(get_stderr_fileno())
30-
config.stash[fault_handler_stderr_key] = open(stderr_fd_copy, "w")
30+
config.stash[fault_handler_stderr_key] = open(
31+
stderr_fd_copy, "w", encoding=sys.stderr.encoding
32+
)
3133
config.stash[fault_handler_originally_enabled_key] = faulthandler.is_enabled()
3234
faulthandler.enable(file=config.stash[fault_handler_stderr_key])
3335

0 commit comments

Comments
 (0)