search for: pyunicode_asutf8str

Displaying 8 results from an estimated 8 matches for "pyunicode_asutf8str".

2012 Aug 25
1
[PATCH] python: Fixed syntax errors in python/guestfs-py.c
...n.ml +++ b/generator/generator_python.ml @@ -391,7 +391,7 @@ free_strings (char **argv) pr " optargs_s.%s = PyString_AsString (py_%s);\n" n n; pr "#else\n"; pr " PyObject *bytes;\n"; - pr " bytes = PyUnicode_AsUTF8String (py_%s));\n" n; + pr " bytes = PyUnicode_AsUTF8String (py_%s);\n" n; pr " optargs_s.%s = PyBytes_AS_STRING (bytes);\n" n; pr "#endif\n"; | OStringList _ -> -- 1.7.9.6 (Apple Git-31.1)
2014 Aug 08
2
[PATCH 1/2] Add type checking, support integers as value
...ring (v, \"key\"); if (!obj) { - PyErr_SetString (PyExc_RuntimeError, \"no 'key' element in dictionary\"); + PyErr_SetString (PyExc_KeyError, \"no 'key' element in dictionary\"); + return -1; + } + if (PyUnicode_Check (obj)) { + bytes = PyUnicode_AsUTF8String (obj); + if (bytes == NULL) { + return -1; + } + } else if (PyBytes_Check (obj)) { + bytes = obj; + } else { + PyErr_SetString (PyExc_TypeError, \"expected bytes or str type for 'key'\"); return -1; } -#ifdef HAVE_PYSTRING_ASSTRING - ret->key = Py...
2017 May 09
1
[PATCH v2] python: add simple wrappers for PyObject<->string functions
...| OString _ -> - pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " optargs_s.%s = PyString_AsString (py_%s);\n" n n; - pr "#else\n"; - pr " PyObject *bytes;\n"; - pr " bytes = PyUnicode_AsUTF8String (py_%s);\n" n; - pr " optargs_s.%s = PyBytes_AS_STRING (bytes);\n" n; - pr "#endif\n"; + pr " optargs_s.%s = guestfs_int_py_asstring (py_%s);\n" n n | OStringList _ -> pr " opta...
2014 Aug 04
6
[hivex] Segfault for an integer value to node_set_value
Hi, When an integer argument is passed as value, node_set_value segfaults. Reproducer is at the end of this message The backtrace points at hivex-py.c, function get_value. While obj is non-NULL, `bytes = PyUnicode_AsUTF8String (obj);` returns NULL. Kind regards, Peter https://lekensteyn.nl #!/usr/bin/env python3 import hivex, sys h = hivex.Hivex(sys.argv[1]) print(h) val = { 'key': 'broken', 't': 4, 'value': 1234 } print(val) r = h.node_set_value(h.root(), val) print(r)
2017 May 09
0
[PATCH] python: add simple wrappers for PyObject<->string functions
...| OString _ -> - pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " optargs_s.%s = PyString_AsString (py_%s);\n" n n; - pr "#else\n"; - pr " PyObject *bytes;\n"; - pr " bytes = PyUnicode_AsUTF8String (py_%s);\n" n; - pr " optargs_s.%s = PyBytes_AS_STRING (bytes);\n" n; - pr "#endif\n"; + pr " optargs_s.%s = guestfs_int_py_asstring (py_%s);\n" n n | OStringList _ -> pr " opta...
2014 Aug 16
7
[hivex] [PATCH 0/6] Python fixes for node_set_value
Hi, This patch series is based on a prior patch[1], splitting off changes as requested and incorporating feedback from Richard Jones. It introduces type validation to avoid segmentation faults (instead, it reports an exception) and fixes handling of the bytes type in Python 3. Major changes since that series: - Drop newly introduced support for integer types for DWORD/QWORDS - Reject Unicode
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...+ if (buf) + free (buf->data); free (buf); } diff --git a/python/utils.c b/python/utils.c index e0929dc..0e3164c 100644 --- a/python/utils.c +++ b/python/utils.c @@ -60,15 +60,24 @@ nbd_internal_py_get_string_list (PyObject *obj) for (i = 0; i < len; ++i) { PyObject *bytes = PyUnicode_AsUTF8String (PyList_GetItem (obj, i)); + if (!bytes) + goto err; r[i] = strdup (PyBytes_AS_STRING (bytes)); + Py_DECREF (bytes); if (r[i] == NULL) { PyErr_NoMemory (); - return NULL; + goto err; } } r[len] = NULL; return r; + + err: + while (i--) + fr...
2020 Jan 09
9
[PATCH 0/7] Various Python cleanups.
Patch #7 depends on: https://www.redhat.com/archives/libguestfs/2020-January/msg00035.html No, Python < 3 support is not dropped yet, however it will be easier after this series. Pino Toscano (7): build: enforce a minimum Python version python: drop code for Python < 2.5 python: assume support for Capsules python: remove compile time check for PyString_AsString python: replace