Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix couple of EncodingWarnings #10954

Merged
merged 3 commits into from
Apr 29, 2023
Merged

Conversation

bluetech
Copy link
Member

See #10328 (comment) for context.

The py.path one might be better to leave as-is, but I lean toward fixing.

bluetech and others added 3 commits April 28, 2023 23:07
We're not supposed to diverge here, but make this change to fix an
unavoidable EncodingWarning that is otherwise raised in pytest's test
suite. The behavior should be exactly the same besides the warning,
hopefully that won't cause confusion.
@@ -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

@bluetech bluetech merged commit 762bb61 into pytest-dev:main Apr 29, 2023
25 checks passed
@bluetech bluetech deleted the fix-encodingwarnings branch April 29, 2023 08:37
@EwoutH
Copy link

EwoutH commented Jun 6, 2023

Thanks for fixing this!

I got the warning in my CI configuration, any idea when a new stable release will be tagged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants