Displaying 18 results from an estimated 18 matches for "pybytes_fromstringandsize".
2017 May 09
1
[PATCH v2] python: add simple wrappers for PyObject<->string functions
...quot; name;
- pr "#ifdef HAVE_PYSTRING_ASSTRING\n";
- pr " PyString_FromStringAndSize (%s->%s, %s->%s_len));\n"
- typ name typ name;
- pr "#else\n";
- pr " PyBytes_FromStringAndSize (%s->%s, %s->%s_len));\n"
- typ name typ name;
- pr "#endif\n"
+ pr " guestfs_int_py_fromstringsize (%s->%s, %s->%s_len));\n"
+ typ name typ name
| name, FUUID ->
pr...
2017 Mar 18
0
[PATCH] python: check return value of Python APIs
...PyString_FromStringAndSize (%s->%s, %s->%s_len));\n"
+ pr " value = PyString_FromStringAndSize (%s->%s, %s->%s_len);\n"
typ name typ name;
pr "#else\n";
- pr " PyBytes_FromStringAndSize (%s->%s, %s->%s_len));\n"
+ pr " value = PyBytes_FromStringAndSize (%s->%s, %s->%s_len);\n"
typ name typ name;
- pr "#endif\n"
+ pr "#endif\n";
+ pr " if (value == NULL) {\n";
+...
2017 Apr 25
1
[Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
...PyString_FromStringAndSize (%s->%s, %s->%s_len));\n"
+ pr " value = PyString_FromStringAndSize (%s->%s, %s->%s_len);\n"
typ name typ name;
pr "#else\n";
- pr " PyBytes_FromStringAndSize (%s->%s, %s->%s_len));\n"
+ pr " value = PyBytes_FromStringAndSize (%s->%s, %s->%s_len);\n"
typ name typ name;
- pr "#endif\n"
+ pr "#endif\n";
+ pr " if (value == NULL) {\n";
+...
2017 May 09
0
[PATCH] python: add simple wrappers for PyObject<->string functions
...quot; name;
- pr "#ifdef HAVE_PYSTRING_ASSTRING\n";
- pr " PyString_FromStringAndSize (%s->%s, %s->%s_len));\n"
- typ name typ name;
- pr "#else\n";
- pr " PyBytes_FromStringAndSize (%s->%s, %s->%s_len));\n"
- typ name typ name;
- pr "#endif\n"
+ pr " guestfs_int_py_fromstringsize (%s->%s, %s->%s_len));\n"
+ typ name typ name
| name, FUUID ->
pr...
2019 Jan 22
0
[PATCH v2 2/2] python: change types for RBufferOut/FBuffer with Python 3 (RHBZ#1661871)
...,13 @@ and generate_python_structs () =
pr " goto err;\n";
pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, FBuffer ->
+ pr "#if PY_MAJOR_VERSION >= 3\n";
+ 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"
typ name typ name;
+ pr "#endif\n";
pr "...
2020 Jan 09
0
[PATCH 5/7] python: replace guestfs_int_py_fromstringsize in Py2 branches
...ator/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"...
2019 Jan 22
3
[PATCH v2 0/2] python: fixes for Python 3
A couple of fixes for Python 3 to the Python binding.
Unfortunately a behaviour change is needed, although it fixes broken
types used.
Changes from v1:
- handle also FBuffer in structs
Pino Toscano (2):
python: fix call of Python handlers of events
python: change types for RBufferOut/FBuffer with Python 3
(RHBZ#1661871)
generator/python.ml | 9 +++++++++
python/handle.c | 3 ++-
2
2019 Jan 22
3
[PATCH 0/2] python: fixes for Python 3
A couple of fixes for Python 3 to the Python binding.
Unfortunately a behaviour change is needed, although it fixes broken
types used.
Pino Toscano (2):
python: fix call of Python handlers of events
python: change return type for RBufferOut with Python 3 (RHBZ#1661871)
generator/python.ml | 4 ++++
python/handle.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
--
2.20.1
2014 Feb 03
1
[PATCH] hivex: python: value_value no longer generates Unicode strings
...r/generator.ml
+++ b/generator/generator.ml
@@ -2981,7 +2981,7 @@ put_val_type (char *val, size_t len, hive_type t)
{
PyObject *r = PyTuple_New (2);
PyTuple_SetItem (r, 0, PyLong_FromLong ((long) t));
- PyTuple_SetItem (r, 1, PyUnicode_DecodeUTF8 (val, len, NULL));
+ PyTuple_SetItem (r, 1, PyBytes_FromStringAndSize (val, len));
return r;
}
diff --git a/python/t/210-setvalue.py b/python/t/210-setvalue.py
index 2ee7ac5..8e7ed5c 100644
--- a/python/t/210-setvalue.py
+++ b/python/t/210-setvalue.py
@@ -19,6 +19,14 @@ import sys
import os
import hivex
+if sys.version >= '3':
+ import codecs...
2017 May 06
5
[Bug 1406906] [PATCH 0/3] Fix segmentation fault in Python bindings
This series addresses the issue where non UTF8 file names in a guest image lead to libguestfs segfault with Python 3 APIs.
The core issue is the APIs are not checking the return value when constructing a new PyObject. Therefore NULL pointers are added to Python collections (lists and dictionaries) crashing the application.
Few notes regarding the comments on the previous patch.
- Added a
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
2019 Jan 22
0
[PATCH 2/2] python: change return type for RBufferOut with Python 3 (RHBZ#1661871)
...1,7 +511,11 @@ and generate_python_actions actions () =
pr " guestfs_int_free_string_list (r);\n";
pr " if (py_r == NULL) goto out;\n";
| RBufferOut _ ->
+ 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 "#endif\n";
pr " free (r);\n";
pr " if (py_r == NULL) goto out;\n";
);
--
2.20.1
2014 Jan 15
0
[PATCH 3/4] hivex: python: Produce Unicode strings in get_* methods
...ist;
@@ -2985,11 +2981,7 @@ put_val_type (char *val, size_t len, hive_type t)
{
PyObject *r = PyTuple_New (2);
PyTuple_SetItem (r, 0, PyLong_FromLong ((long) t));
-#ifdef HAVE_PYSTRING_ASSTRING
- PyTuple_SetItem (r, 1, PyString_FromStringAndSize (val, len));
-#else
- PyTuple_SetItem (r, 1, PyBytes_FromStringAndSize (val, len));
-#endif
+ PyTuple_SetItem (r, 1, PyUnicode_DecodeUTF8 (val, len, NULL));
return r;
}
@@ -3194,17 +3186,10 @@ put_val_type (char *val, size_t len, hive_type t)
if f_len_exists name then
pr " size_t sz = hivex_%s_len (%s);\n"
na...
2015 Feb 14
0
[PATCH] python: Call PyErr_Clear() on non-error paths out of the Python bindings.
...goto out;\n";
| RStringList _ ->
pr " py_r = put_string_list (r);\n";
pr " guestfs_int_free_string_list (r);\n"
@@ -492,10 +495,18 @@ put_table (char * const * const argv)
pr "#else\n";
pr " py_r = PyBytes_FromStringAndSize (r, size);\n";
pr "#endif\n";
- pr " free (r);\n"
+ pr " free (r);\n";
+ pr " if (py_r == NULL) goto out;\n";
);
+ (* As this is the non-error path, clear the Python error
+ * indicator fla...
2014 Jan 15
4
[PATCH 1/4] hivex: Python 2.6 does not have sysconfig.
---
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6785037..203f34f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,8 +329,8 @@ AS_IF([test "x$enable_python" != "xno"],
AC_MSG_CHECKING([for Python extension suffix (PEP-3149)])
if test -z "$PYTHON_EXT_SUFFIX"; then
2017 May 21
3
[PATCH 0/2] python: improved UTF8 decoding error handling
The Python 3 bindings currently are unable to deal with non UTF8 characters.
This series continues what proposed in RHBZ#1406906.
A new function 'set_decode_error_handler' allows the User to specify
how to deal with decoding errors.
The default behaviour will be raising a UnicodeDecodeError.
If the handler is changed to 'surrogateescape', non UTF8 characters will be escaped
in a
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
...th n -> pr ", %s" n
| SockAddrAndLen (n, _) -> pr ", /* XXX */ (void *) %s, 0" n
| String n -> pr ", %s" n
@@ -4339,7 +4305,6 @@ let print_python_binding name { args; ret; may_set_error } =
| BytesOut (n, count) ->
pr " py_ret = PyBytes_FromStringAndSize (%s, %s);\n" n count;
use_ret := false
- | ArrayAndLen _
| Bool _
| BytesIn _
| BytesPersistIn _ | BytesPersistOut _
@@ -4347,7 +4312,6 @@ let print_python_binding name { args; ret; may_set_error } =
| Flags _
| Int _
| Int64 _
- | Mutable _
| P...
2019 Aug 09
4
[PATCH libnbd 0/2] generator: Preparatory changes to the generator.
These are some simplifications to the generator. They don't probably
make much sense on their own, but they are preparatory to better
handling of enums, and or'd lists of flags.
Rich.