Skip to content

Commit

Permalink
Better documentation for pygame.sound.copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Borishkof committed Nov 27, 2024
1 parent 3be9a1c commit 726244d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/reST/ref/mixer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ The following file formats are supported
| :sg:`copy() -> Sound`
Return a new Sound object that is a deep copy of this one. The new Sound will
be playable just like the original. If the copy fails, the method returns ``NULL``.
be playable just like the original. If the copy fails, a ``MemoryError`` or a
:meth:`pygame.error` exception will be raised.

.. ## Sound.copy ##
Expand Down
5 changes: 3 additions & 2 deletions src_c/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ snd_copy(PyObject *self, PyObject *_null)
new_sound =
(pgSoundObject *)pgSound_Type.tp_new(Py_TYPE(self), NULL, NULL);
if (!new_sound) {
PyErr_SetString(PyExc_RuntimeError,
PyErr_SetString(PyExc_MemoryError,
"Failed to allocate memory for new sound object");
return NULL;
}
Expand All @@ -867,7 +867,7 @@ snd_copy(PyObject *self, PyObject *_null)
if (!new_chunk) {
free(buffer_copy);
Py_DECREF(new_sound);
PyErr_SetString(PyExc_RuntimeError,
PyErr_SetString(pgExc_SDLError,
"Failed to create new sound chunk");
return NULL;
}
Expand Down Expand Up @@ -909,6 +909,7 @@ PyMethodDef sound_methods[] = {
{"get_length", snd_get_length, METH_NOARGS, DOC_MIXER_SOUND_GETLENGTH},
{"get_raw", snd_get_raw, METH_NOARGS, DOC_MIXER_SOUND_GETRAW},
{"copy", snd_copy, METH_NOARGS, DOC_MIXER_SOUND_COPY},
{"__copy__", snd_copy, METH_NOARGS, DOC_MIXER_SOUND_COPY},
{NULL, NULL, 0, NULL}};

static PyGetSetDef sound_getset[] = {
Expand Down

0 comments on commit 726244d

Please sign in to comment.