[libxml2] Build the Python extension with PY_SSIZE_T_CLEAN



commit f42a0524c693a6d52e95a37c9cf04df1be48262c
Author: Victor Stinner <vstinner python org>
Date:   Mon Nov 9 18:19:31 2020 +0100

    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 <Python.h>\n")
     wrapper.write("#include <libxml/xmlversion.h>\n")
     wrapper.write("#include <libxml/tree.h>\n")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]