Files which failed to open are attempted to be closed on windows
https://github.com/TaylorSMarks/playsound/blob/cff129a2dd712f78bb4773412b293d737dbfc6e9/playsound.py#L72-L77
The try block contains the open call, which when fails tries to close an unopened file leading to a duplicate error being logged, for example
In [2]: playsound.playsound("invalid path")
Error 263 for command:
open "invalid path"
The specified device is not open or is not recognized by MCI.
Error 263 for command:
close "invalid path"
The specified device is not open or is not recognized by MCI.
Failed to close the file: "invalid path"
---------------------------------------------------------------------------
PlaysoundException Traceback (most recent call last)
<ipython-input-2-bb3b5c244808> in <module>
----> 1 playsound.playsound("invalid path")
D:\pycon\playsound\playsound.py in _playsoundWin(sound, block)
53 try:
54 logger.debug('Starting')
---> 55 winCommand(u'open {}'.format(sound))
56 winCommand(u'play {}{}'.format(sound, ' wait' if block else ''))
57 logger.debug('Returning')
D:\pycon\playsound\playsound.py in winCommand(*command)
48 '\n ' + errorBuffer.value)
49 logger.error(exceptionMessage)
---> 50 raise PlaysoundException(exceptionMessage)
51 return buf.value
52
PlaysoundException:
Error 263 for command:
open "invalid path"
The specified device is not open or is not recognized by MCI.
The logger also logs the message which is passed through to the exception leading to it being duplicated, is that intentional for cases where the exception is handled?
I haven’t put much thought into what the logger should do. You’ll note that the logs are completely different on each OS.
Taylor
Sent from my iPhone
On Jul 30, 2021, at 08:18, Numerlor @.***> wrote:
https://github.com/TaylorSMarks/playsound/blob/cff129a2dd712f78bb4773412b293d737dbfc6e9/playsound.py#L72-L77
The try block contains the open call, which when files tries to close an unopened file leading to a duplicate error being logged, for example
In [2]: playsound.playsound("invalid path")
Error 263 for command: open "invalid path" The specified device is not open or is not recognized by MCI. Error 263 for command: close "invalid path" The specified device is not open or is not recognized by MCI.Failed to close the file: "invalid path"
PlaysoundException Traceback (most recent call last)
in ----> 1 playsound.playsound("invalid path") D:\pycon\playsound\playsound.py in _playsoundWin(sound, block) 53 try: 54 logger.debug('Starting') ---> 55 winCommand(u'open {}'.format(sound)) 56 winCommand(u'play {}{}'.format(sound, ' wait' if block else '')) 57 logger.debug('Returning')
D:\pycon\playsound\playsound.py in winCommand(*command) 48 '\n ' + errorBuffer.value) 49 logger.error(exceptionMessage) ---> 50 raise PlaysoundException(exceptionMessage) 51 return buf.value 52
PlaysoundException: Error 263 for command: open "invalid path" The specified device is not open or is not recognized by MCI. The logger also logs the message which is passed through to the exception leading to it being duplicated, is that intentional for cases where the exception is handled?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.