]> granicus.if.org Git - python/commitdiff
Issue #6317: Now winsound.PlaySound only accepts unicode with MvL's approval.
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 7 Nov 2010 14:29:26 +0000 (14:29 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 7 Nov 2010 14:29:26 +0000 (14:29 +0000)
Misc/NEWS
PC/winsound.c

index e541d61e970f0ca6c8c3d386a75ea9ac490895c8..5569bcd4dd33e365dfe590cfbb721c54a491d947 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -251,6 +251,8 @@ Library
 Extension Modules
 -----------------
 
+- Issue #6317: Now winsound.PlaySound only accepts unicode.
+
 - Issue #6317: Now winsound.PlaySound can accept non ascii filename.
 
 - Issue #9377: Use Unicode API for gethostname on Windows.
index d45584868650678938db272736ee3f25b4183df2..1ed95bac4230451e6ed9ccbfa8b46bed1f2150d1 100644 (file)
@@ -73,8 +73,6 @@ static PyObject *
 sound_playsound(PyObject *s, PyObject *args)
 {
     Py_UNICODE *wsound;
-    PyObject *osound;
-    const char *sound;
     int flags;
     int ok;
 
@@ -95,31 +93,7 @@ sound_playsound(PyObject *s, PyObject *args)
         Py_INCREF(Py_None);
         return Py_None;
     }
-    /* Drop the argument parsing error as narrow strings
-       are also valid. */
-    PyErr_Clear();
-    if (!PyArg_ParseTuple(args, "O&i:PlaySound",
-                          PyUnicode_FSConverter, &osound, &flags))
-        return NULL;
-    if (flags & SND_ASYNC && flags & SND_MEMORY) {
-        /* Sidestep reference counting headache; unfortunately this also
-           prevent SND_LOOP from memory. */
-        PyErr_SetString(PyExc_RuntimeError, "Cannot play asynchronously from memory");
-        Py_DECREF(osound);
-        return NULL;
-    }
-    sound = PyBytes_AsString(osound);
-    Py_BEGIN_ALLOW_THREADS
-    ok = PlaySoundA(sound, NULL, flags);
-    Py_END_ALLOW_THREADS
-    if (!ok) {
-        PyErr_SetString(PyExc_RuntimeError, "Failed to play sound");
-        Py_DECREF(osound);
-        return NULL;
-    }
-    Py_DECREF(osound);
-    Py_INCREF(Py_None);
-    return Py_None;
+    return NULL;
 }
 
 static PyObject *