[Python-checkins] r86300 - in python/branches/py3k: Misc/NEWS PC/winsound.c

hirokazu.yamamoto python-checkins at python.org
Sun Nov 7 15:29:27 CET 2010


Author: hirokazu.yamamoto
Date: Sun Nov  7 15:29:26 2010
New Revision: 86300

Log:
Issue #6317: Now winsound.PlaySound only accepts unicode with MvL's approval.

Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/PC/winsound.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sun Nov  7 15:29:26 2010
@@ -251,6 +251,8 @@
 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.

Modified: python/branches/py3k/PC/winsound.c
==============================================================================
--- python/branches/py3k/PC/winsound.c	(original)
+++ python/branches/py3k/PC/winsound.c	Sun Nov  7 15:29:26 2010
@@ -73,8 +73,6 @@
 sound_playsound(PyObject *s, PyObject *args)
 {
     Py_UNICODE *wsound;
-    PyObject *osound;
-    const char *sound;
     int flags;
     int ok;
 
@@ -95,31 +93,7 @@
         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 *


More information about the Python-checkins mailing list