diff options
author | Victor Stinner <vstinner@python.org> | 2023-10-17 13:57:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-17 13:57:10 (GMT) |
commit | 6db6b30ac2734b94f66166cee320028c4ba1d30e (patch) | |
tree | 017752add1a338e9f1d53e8cfd3d9124acf5e81f /PC/winsound.c | |
parent | 198aa67d4ceb5298c3c60f7a77524f5ba084c121 (diff) | |
download | cpython-6db6b30ac2734b94f66166cee320028c4ba1d30e.zip cpython-6db6b30ac2734b94f66166cee320028c4ba1d30e.tar.gz cpython-6db6b30ac2734b94f66166cee320028c4ba1d30e.tar.bz2 |
gh-85283: Build winsound extension with limited C API (#110978)
Replace type->tp_name with PyType_GetQualName().
Diffstat (limited to 'PC/winsound.c')
-rw-r--r-- | PC/winsound.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/PC/winsound.c b/PC/winsound.c index 2881490..ae36936 100644 --- a/PC/winsound.c +++ b/PC/winsound.c @@ -35,10 +35,8 @@ winsound.PlaySound(None, 0) */ -// clinic/winsound.c.h uses internal pycore_modsupport.h API -#ifndef Py_BUILD_CORE_BUILTIN -# define Py_BUILD_CORE_MODULE 1 -#endif +// Need limited C API version 3.13 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED +#define Py_LIMITED_API 0x030d0000 #include <Python.h> #include <windows.h> @@ -100,9 +98,13 @@ winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags) } wsound = (wchar_t *)view.buf; } else if (PyBytes_Check(sound)) { - PyErr_Format(PyExc_TypeError, - "'sound' must be str, os.PathLike, or None, not '%s'", - Py_TYPE(sound)->tp_name); + PyObject *type_name = PyType_GetQualName(Py_TYPE(sound)); + if (type_name != NULL) { + PyErr_Format(PyExc_TypeError, + "'sound' must be str, os.PathLike, or None, not %S", + type_name); + Py_DECREF(type_name); + } return NULL; } else { PyObject *obj = PyOS_FSPath(sound); |