Index: PC/winsound.c =================================================================== --- PC/winsound.c (revision 73491) +++ PC/winsound.c (working copy) @@ -72,14 +72,13 @@ static PyObject * sound_playsound(PyObject *s, PyObject *args) { - const char *sound; + PyObject *o; + char *sound; int flags; - int length; int ok; - if(!PyArg_ParseTuple(args,"z#i:PlaySound",&sound,&length,&flags)) { + if (!PyArg_ParseTuple(args, "Oi:PlaySound", &o, &flags)) return NULL; - } if(flags&SND_ASYNC && flags &SND_MEMORY) { /* Sidestep reference counting headache; unfortunately this also @@ -88,9 +87,21 @@ return NULL; } - Py_BEGIN_ALLOW_THREADS - ok = PlaySound(sound,NULL,flags); - Py_END_ALLOW_THREADS + if (o == Py_None || PyUnicode_Check(o)) { + Py_BEGIN_ALLOW_THREADS + ok = PlaySoundW(o == Py_None ? NULL : PyUnicode_AsUnicode(o), NULL, flags); + Py_END_ALLOW_THREADS + } + else { + PyErr_Clear(); + if (!PyArg_ParseTuple(args, "eti:PlaySound", Py_FileSystemDefaultEncoding, &sound, &flags)) + return NULL; + Py_BEGIN_ALLOW_THREADS + ok = PlaySoundA(sound, NULL, flags); + Py_END_ALLOW_THREADS + PyMem_Free(sound); + } + if(!ok) { PyErr_SetString(PyExc_RuntimeError,"Failed to play sound");