Skip to content

Conversation

@moribellamy
Copy link
Contributor

No description provided.

@moribellamy moribellamy requested a review from a team as a code owner April 12, 2022 23:37
@ghost
Copy link

ghost commented Apr 12, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@arhadthedev
Copy link
Member

While the autolinker bot is being enhanced, here is a link so the readers of the PR can jump here via an autogenerated line back there: gh-91061.

@moribellamy
Copy link
Contributor Author

@JelleZijlstra any more comments? i updated the error message since you last looked.

PC/winsound.c Outdated
wsound = (wchar_t *)view.buf;
} else if (PyBytes_Check(sound)) {
PyErr_Format(PyExc_TypeError,
"'sound' must be str, os.PathLike, or None; not '%s'",
Copy link
Member

Choose a reason for hiding this comment

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

Minor fix:

Suggested change
"'sound' must be str, os.PathLike, or None; not '%s'",
"'sound' must be str, os.PathLike, or None, not '%s'",

Bigger question: What if we have a subclass of bytes that also is a PathLike resolving to a str? How is that case handled elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK the PathLike in test_winsound.py::PlaySoundTest.test_snd_filepath() (on line 129) resolves to str, so we have that covered

Copy link
Member

Choose a reason for hiding this comment

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

That one isn't a bytes subclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i see. an object fitting that description would pass straight through PyOS_FSPath, without calling fspath on it first. open() would exhibit the same behavior, since open() passes a pyobject to PyOS_FSPath as well without checking for this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see _io_open_impl in _iomodule.c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JelleZijlstra to recap, open() would treat that kind of object by looking at the bytes object x itself, and would not try x.__fspath__(). this code, as it stands, does the same thing. what should we do?

Co-authored-by: Jelle Zijlstra <[email protected]>
@moribellamy moribellamy requested a review from JelleZijlstra May 22, 2022 23:44
@JelleZijlstra JelleZijlstra self-assigned this May 23, 2022
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.

6 participants