From f42a0524c693a6d52e95a37c9cf04df1be48262c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 9 Nov 2020 18:19:31 +0100 Subject: [PATCH] Build the Python extension with PY_SSIZE_T_CLEAN The Python extension module now uses Py_ssize_t rather than int for string lengths. This change makes the extension compatible with Python 3.10. Fixes #203. --- python/generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/generator.py b/python/generator.py index c0cb3add..59d45e00 100755 --- a/python/generator.py +++ b/python/generator.py @@ -393,7 +393,7 @@ def print_function_wrapper(name, output, export, include): format_args = format_args + ", &%s" % (arg[0]) if f == 's#': format_args = format_args + ", &py_buffsize%d" % num_bufs - c_args = c_args + " int py_buffsize%d;\n" % num_bufs + c_args = c_args + " Py_ssize_t py_buffsize%d;\n" % num_bufs num_bufs = num_bufs + 1 if c_call != "": c_call = c_call + ", " @@ -555,6 +555,7 @@ def buildStubs(): export.write("/* Generated */\n\n") wrapper = open("libxml2-py.c", "w") wrapper.write("/* Generated */\n\n") + wrapper.write("#define PY_SSIZE_T_CLEAN\n") wrapper.write("#include \n") wrapper.write("#include \n") wrapper.write("#include \n")