[New-bugs-announce] [issue46905] winsound.PlaySound should accept pathlib.Path instances

Julian report at bugs.python.org
Wed Mar 2 19:02:59 EST 2022

New submission from Julian <github at somethinkodd.com>:

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.

components: Library (Lib)
messages: 414393
nosy: Julian-O
priority: normal
severity: normal
status: open
title: winsound.PlaySound should accept pathlib.Path instances
type: enhancement

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list