diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-10-16 07:55:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-10-16 07:58:32 +0300 |
commit | 9dd5e3b6e89ca0be4207e64439f292519eaf7e6e (patch) | |
tree | ac2df89fdbdc770a8c790ba740d2c55dd09cf9de /source/blender/python/generic | |
parent | 36b6fb5cd600a7067d24cfe836c0af4d94e083e4 (diff) |
Cleanup: define PY_SSIZE_T_CLEAN for Python
Silence deprecation warnings running with Python 3.8.
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r-- | source/blender/python/generic/blf_py_api.c | 5 | ||||
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index b90483e89b9..62f5a568ee1 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -20,6 +20,9 @@ * This file defines the 'bgl' module, used for drawing text in OpenGL. */ +/* Future-proof, See https://docs.python.org/3/c-api/arg.html#strings-and-buffers */ +#define PY_SSIZE_T_CLEAN + #include <Python.h> #include "blf_py_api.h" @@ -176,7 +179,7 @@ PyDoc_STRVAR(py_blf_draw_doc, static PyObject *py_blf_draw(PyObject *UNUSED(self), PyObject *args) { const char *text; - int text_length; + Py_ssize_t text_length; int fontid; if (!PyArg_ParseTuple(args, "is#:blf.draw", &fontid, &text, &text_length)) { diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 66cb4cc0bf3..c85a1d9ba05 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -25,6 +25,9 @@ * BLI_string_utf8() for unicode conversion. */ +/* Future-proof, See https://docs.python.org/3/c-api/arg.html#strings-and-buffers */ +#define PY_SSIZE_T_CLEAN + #include <Python.h> #include <frameobject.h> @@ -873,7 +876,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...) va_list vargs; - int *sizes = PyMem_MALLOC(sizeof(int) * (n / 2)); + Py_ssize_t *sizes = PyMem_MALLOC(sizeof(*sizes) * (n / 2)); int i; PyObject *py_dict = PyC_DefaultNameSpace(filepath); |