diff -r d0302d8ecbc1 Doc/library/winsound.rst --- a/Doc/library/winsound.rst Wed Aug 10 01:05:56 2016 -0500 +++ b/Doc/library/winsound.rst Sun Aug 14 15:55:49 2016 -0500 @@ -39,7 +39,8 @@ sound to play; possible values are ``-1``, ``MB_ICONASTERISK``, ``MB_ICONEXCLAMATION``, ``MB_ICONHAND``, ``MB_ICONQUESTION``, and ``MB_OK``, all described below. The value ``-1`` produces a "simple beep"; this is the final - fallback if a sound cannot be played otherwise. + fallback if a sound cannot be played otherwise. If the system indicates an + error, :exc:`RuntimeError` is raised. .. data:: SND_FILENAME diff -r d0302d8ecbc1 PC/winsound.c --- a/PC/winsound.c Wed Aug 10 01:05:56 2016 -0500 +++ b/PC/winsound.c Sun Aug 14 15:55:49 2016 -0500 @@ -148,7 +148,17 @@ winsound_MessageBeep_impl(PyObject *module, int x) /*[clinic end generated code: output=1ad89e4d8d30a957 input=a776c8a85c9853f6]*/ { - MessageBeep(x); + BOOL ok; + + Py_BEGIN_ALLOW_THREADS + ok = MessageBeep(x); + Py_END_ALLOW_THREADS + + if (!ok) { + PyErr_SetExcFromWindowsErr(PyExc_RuntimeError, 0); + return NULL; + } + Py_RETURN_NONE; }