-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
winsound.PlaySound should accept pathlib.Path instances #91061
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
Comments
The library function winsound.PlaySound takes a sound parameter. One of the valid arguments is a path to a WAV filename. Since Python 3.4, paths can be cleanly represented with PathLib.Path instances. However, if you pass a Path instance to PlaySound, it responds with: TypeError: 'sound' must be str or None, not 'WindowsPath' This can be quickly fixed in the caller by passing str(the_path_instance) instead, but it would be cleaner if PlaySound accepted Python's preferred method of representing paths. |
PlaySound() is implemented by the C function winsound_PlaySound_impl() in "PC/winsound.c". To support pathlike objects, it could use |
I'm interested in trying this issue. What's an appropriate way to test the fix in CI? I'm assuming manual testing will be straightforward (just build the binary and have a simple script that tries to use a PathLib.Path instead of a string) |
About the best you can do is replicate this test: cpython/Lib/test/test_winsound.py Lines 115 to 117 in f33e2c8
pathlib.Path(fn) instead of just fn .
|
Thanks all. My first ever python PR is out. Looking forward to learning how to do things properly :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: