Skip to content

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.
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
@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.

4 participants