diff options
author | Zachary Ware <zachary.ware@gmail.com> | 2016-09-05 22:32:28 (GMT) |
---|---|---|
committer | Zachary Ware <zachary.ware@gmail.com> | 2016-09-05 22:32:28 (GMT) |
commit | 625cb379f7e77457ca5be94e175d4b71a1d8989f (patch) | |
tree | 3175d098fdd598def14b4cbce5de2e1a603c60c5 | |
parent | cefebf3cbe72b468bacc57c37f183712529058f9 (diff) | |
download | cpython-625cb379f7e77457ca5be94e175d4b71a1d8989f.zip cpython-625cb379f7e77457ca5be94e175d4b71a1d8989f.tar.gz cpython-625cb379f7e77457ca5be94e175d4b71a1d8989f.tar.bz2 |
Issue #25387: Check return value of winsound.MessageBeep
-rw-r--r-- | Doc/library/winsound.rst | 3 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | PC/winsound.c | 12 |
3 files changed, 15 insertions, 2 deletions
diff --git a/Doc/library/winsound.rst b/Doc/library/winsound.rst index e72d025..372f792 100644 --- a/Doc/library/winsound.rst +++ b/Doc/library/winsound.rst @@ -40,7 +40,8 @@ provided by Windows platforms. It includes functions and several constants. 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 @@ -80,6 +80,8 @@ Core and Builtins Library ------- +- Issue #25387: Check return value of winsound.MessageBeep. + - Issue #27866: Add SSLContext.get_ciphers() method to get a list of all enabled ciphers. diff --git a/PC/winsound.c b/PC/winsound.c index 000ddd8..7e06b7b 100644 --- a/PC/winsound.c +++ b/PC/winsound.c @@ -175,7 +175,17 @@ static PyObject * 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; } |