From ed3dedfc0735d818aea13dab76debbe13bf410ff Mon Sep 17 00:00:00 2001 From: AN Long Date: Tue, 18 Mar 2025 23:25:24 +0900 Subject: [PATCH 1/6] Add some missing SND_* macros --- Doc/library/winsound.rst | 15 +++++++++++++++ Lib/test/test_winsound.py | 9 +++++++++ PC/winsound.c | 8 +++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Doc/library/winsound.rst b/Doc/library/winsound.rst index 799fb3dea19501..eeec95f99f7118 100644 --- a/Doc/library/winsound.rst +++ b/Doc/library/winsound.rst @@ -142,6 +142,21 @@ provided by Windows platforms. It includes functions and several constants. to specify an application-defined sound alias. +.. data:: SND_SENTRY + + Triggers a SoundSentry event when the sound is played. + + +.. data:: SND_SYNC + + The sound is played synchronously. This is the default behavior. + + +.. data:: SND_SYSTEM + + Assign the sound to the audio session for system notification sounds. + + .. data:: MB_ICONASTERISK Play the ``SystemDefault`` sound. diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py index 870ab7bd41d8ce..fc22274fce8ab9 100644 --- a/Lib/test/test_winsound.py +++ b/Lib/test/test_winsound.py @@ -161,6 +161,15 @@ def test_stopasync(self): # does not raise on systems without a sound card. winsound.PlaySound(None, winsound.SND_PURGE) + def test_sound_sentry(self): + safe_PlaySound("SystemExit", winsound.SND_ALIAS | winsound.SND_SENTRY) + + def test_sound_sync(self): + safe_PlaySound("SystemExit", winsound.SND_ALIAS | winsound.SND_SYNC) + + def test_sound_system(self): + safe_PlaySound("SystemExit", winsound.SND_ALIAS | winsound.SND_SYSTEM) + if __name__ == "__main__": unittest.main() diff --git a/PC/winsound.c b/PC/winsound.c index 1cb42f2f3bdfc6..b4243ad65438a5 100644 --- a/PC/winsound.c +++ b/PC/winsound.c @@ -56,7 +56,10 @@ PyDoc_STRVAR(sound_module_doc, "SND_NODEFAULT - Do not play a default beep if the sound can not be found\n" "SND_NOSTOP - Do not interrupt any sounds currently playing\n" // Raising RuntimeError if needed "SND_NOWAIT - Return immediately if the sound driver is busy\n" // Without any errors -"SND_APPLICATION - sound is an application-specific alias in the registry." +"SND_APPLICATION - sound is an application-specific alias in the registry.\n" +"SND_SENTRY - Triggers a SoundSentry event when the sound is played.\n" +"SND_SYNC - Play the sound synchronously, default behavior.\n" +"SND_SYSTEM - Assign sound to the audio session for system notification sounds.\n" "\n" "Beep(frequency, duration) - Make a beep through the PC speaker.\n" "MessageBeep(type) - Call Windows MessageBeep."); @@ -232,6 +235,9 @@ exec_module(PyObject *module) ADD_DEFINE(SND_PURGE); ADD_DEFINE(SND_LOOP); ADD_DEFINE(SND_APPLICATION); + ADD_DEFINE(SND_SENTRY); + ADD_DEFINE(SND_SYNC); + ADD_DEFINE(SND_SYSTEM); ADD_DEFINE(MB_OK); ADD_DEFINE(MB_ICONASTERISK); From 4899d34d07dbea7dfc33ad7bc116073cd3d46bc2 Mon Sep 17 00:00:00 2001 From: AN Long Date: Wed, 19 Mar 2025 00:00:17 +0900 Subject: [PATCH 2/6] Add missing MB_* constants --- Doc/library/winsound.rst | 19 +++++++++++++++++++ Lib/test/test_winsound.py | 12 ++++++++++++ PC/winsound.c | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/Doc/library/winsound.rst b/Doc/library/winsound.rst index eeec95f99f7118..46e4cfc8f968f3 100644 --- a/Doc/library/winsound.rst +++ b/Doc/library/winsound.rst @@ -181,3 +181,22 @@ provided by Windows platforms. It includes functions and several constants. Play the ``SystemDefault`` sound. + +.. data:: MB_ICONERROR + + Play the ``SystemHand`` sound. + + +.. data:: MB_ICONINFORMATION + + Play the ``SystemDefault`` sound. + + +.. data:: MB_ICONSTOP + + Play the ``SystemHand`` sound. + + +.. data:: MB_ICONWARNING + + Play the ``SystemExclamation`` sound. \ No newline at end of file diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py index fc22274fce8ab9..9724d830ade0b4 100644 --- a/Lib/test/test_winsound.py +++ b/Lib/test/test_winsound.py @@ -82,6 +82,18 @@ def test_hand(self): def test_question(self): safe_MessageBeep(winsound.MB_ICONQUESTION) + def test_error(self): + safe_MessageBeep(winsound.MB_ICONERROR) + + def test_information(self): + safe_MessageBeep(winsound.MB_ICONINFORMATION) + + def test_stop(self): + safe_MessageBeep(winsound.MB_ICONSTOP) + + def test_warning(self): + safe_MessageBeep(winsound.MB_ICONWARNING) + def test_keyword_args(self): safe_MessageBeep(type=winsound.MB_OK) diff --git a/PC/winsound.c b/PC/winsound.c index b4243ad65438a5..f485c2c5972b01 100644 --- a/PC/winsound.c +++ b/PC/winsound.c @@ -244,6 +244,10 @@ exec_module(PyObject *module) ADD_DEFINE(MB_ICONEXCLAMATION); ADD_DEFINE(MB_ICONHAND); ADD_DEFINE(MB_ICONQUESTION); + ADD_DEFINE(MB_ICONERROR); + ADD_DEFINE(MB_ICONINFORMATION); + ADD_DEFINE(MB_ICONSTOP); + ADD_DEFINE(MB_ICONWARNING); #undef ADD_DEFINE From 6c9aea6031ea6d78cae8ab96c83421ade38bf289 Mon Sep 17 00:00:00 2001 From: AN Long Date: Wed, 19 Mar 2025 21:58:33 +0900 Subject: [PATCH 3/6] blurb it --- .../next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst diff --git a/Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst b/Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst new file mode 100644 index 00000000000000..174fadcbf2eb43 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst @@ -0,0 +1,2 @@ +Some :data:`!SND_*` and :data:`!MB_*` constants are added to +:module:`winsound`. From 2610d9f8787f2b0bab74b856a34d76607ce5a61a Mon Sep 17 00:00:00 2001 From: AN Long Date: Wed, 19 Mar 2025 22:02:12 +0900 Subject: [PATCH 4/6] Add new line to make sphinx-lint happy --- Doc/library/winsound.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/winsound.rst b/Doc/library/winsound.rst index 46e4cfc8f968f3..d2f6744634a5d9 100644 --- a/Doc/library/winsound.rst +++ b/Doc/library/winsound.rst @@ -199,4 +199,4 @@ provided by Windows platforms. It includes functions and several constants. .. data:: MB_ICONWARNING - Play the ``SystemExclamation`` sound. \ No newline at end of file + Play the ``SystemExclamation`` sound. From 2f8d35c26373b5da0277d5938665d3d5cb40bce5 Mon Sep 17 00:00:00 2001 From: AN Long Date: Wed, 19 Mar 2025 22:19:22 +0900 Subject: [PATCH 5/6] Fix news entry --- .../Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst b/Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst index 174fadcbf2eb43..4f44c091745700 100644 --- a/Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst +++ b/Misc/NEWS.d/next/Windows/2025-03-19-21-58-16.gh-issue-131453.qQ4J5H.rst @@ -1,2 +1 @@ -Some :data:`!SND_*` and :data:`!MB_*` constants are added to -:module:`winsound`. +Some :data:`!SND_*` and :data:`!MB_*` constants are added to :mod:`winsound`. From 9136bf7b38f0695f53be2343d59b1c0e8f808afa Mon Sep 17 00:00:00 2001 From: AN Long Date: Thu, 20 Mar 2025 19:13:38 +0900 Subject: [PATCH 6/6] Add versionadded markers on document --- Doc/library/winsound.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/winsound.rst b/Doc/library/winsound.rst index d2f6744634a5d9..925984c3cdb0cb 100644 --- a/Doc/library/winsound.rst +++ b/Doc/library/winsound.rst @@ -146,16 +146,22 @@ provided by Windows platforms. It includes functions and several constants. Triggers a SoundSentry event when the sound is played. + .. versionadded:: 3.14 + .. data:: SND_SYNC The sound is played synchronously. This is the default behavior. + .. versionadded:: 3.14 + .. data:: SND_SYSTEM Assign the sound to the audio session for system notification sounds. + .. versionadded:: 3.14 + .. data:: MB_ICONASTERISK @@ -186,17 +192,25 @@ provided by Windows platforms. It includes functions and several constants. Play the ``SystemHand`` sound. + .. versionadded:: 3.14 + .. data:: MB_ICONINFORMATION Play the ``SystemDefault`` sound. + .. versionadded:: 3.14 + .. data:: MB_ICONSTOP Play the ``SystemHand`` sound. + .. versionadded:: 3.14 + .. data:: MB_ICONWARNING Play the ``SystemExclamation`` sound. + + .. versionadded:: 3.14