[Python-checkins] r81640 - python/trunk/Lib/test/test_winsound.py

brian.curtin python-checkins at python.org
Tue Jun 1 15:29:13 CEST 2010


Author: brian.curtin
Date: Tue Jun  1 15:29:13 2010
New Revision: 81640

Log:
Fix #8618. Ask the Windows mixer API if there are any playback devices
configured before attempting to test PlaySound.


Modified:
   python/trunk/Lib/test/test_winsound.py

Modified: python/trunk/Lib/test/test_winsound.py
==============================================================================
--- python/trunk/Lib/test/test_winsound.py	(original)
+++ python/trunk/Lib/test/test_winsound.py	Tue Jun  1 15:29:13 2010
@@ -5,6 +5,7 @@
 import time
 import os
 import subprocess
+import ctypes
 
 winsound = test_support.import_module('winsound')
 import _winreg
@@ -12,6 +13,11 @@
 def has_sound(sound):
     """Find out if a particular event is configured with a default sound"""
     try:
+        # Ask the mixer API for the number of devices it knows about.
+        # When there are no devices, PlaySound will fail.
+        if ctypes.windll.winmm.mixerGetNumDevs() is 0:
+            return False
+
         key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER,
                 "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
         value = _winreg.EnumValue(key, 0)[1]


More information about the Python-checkins mailing list