Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/_pytest/_py/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def ensure(self, *args, **kwargs):
else:
p.dirpath()._ensuredirs()
if not p.check(file=1):
p.open("w").close()
p.open("wb").close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To just touch the file, pathlib uses the below pattern -- this might be a larger change than wanted, though:

Suggested change
p.open("wb").close()
os.close(os.open(self.strpath, flags=os.O_CREAT))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code Was strictly copied in to enable drop of the py dep, so let's go for minimal changes instead of nice ones as we want to shed it as soon as possible

return p

@overload
Expand Down
4 changes: 3 additions & 1 deletion src/_pytest/faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ 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])

Expand Down