[Libguestfs] [PATCH 5/7] python: replace guestfs_int_py_fromstringsize in Py2 branches

Pino Toscano ptoscano at redhat.com
Thu Jan 9 17:37:48 UTC 2020


In Python 2 code branches use PyString_FromStringAndSize directly
instead of the guestfs_int_py_fromstringsize wrapper (which calls
PyString_FromStringAndSize anyway on Python < 3).
---
 generator/python.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generator/python.ml b/generator/python.ml
index 2a1a48fc0..0e1ed20d8 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -178,7 +178,7 @@ and generate_python_structs () =
             pr "  value = PyBytes_FromStringAndSize (%s->%s, %s->%s_len);\n"
               typ name typ name;
             pr "#else\n";
-            pr "  value = guestfs_int_py_fromstringsize (%s->%s, %s->%s_len);\n"
+            pr "  value = PyString_FromStringAndSize (%s->%s, %s->%s_len);\n"
               typ name typ name;
             pr "#endif\n";
             pr "  if (value == NULL)\n";
@@ -496,7 +496,7 @@ and generate_python_actions actions () =
            pr "#if PY_MAJOR_VERSION >= 3\n";
            pr "  py_r = PyBytes_FromStringAndSize (r, size);\n";
            pr "#else\n";
-           pr "  py_r = guestfs_int_py_fromstringsize (r, size);\n";
+           pr "  py_r = PyString_FromStringAndSize (r, size);\n";
            pr "#endif\n";
            pr "  free (r);\n";
            pr "  if (py_r == NULL) goto out;\n";
-- 
2.24.1




More information about the Libguestfs mailing list