search for: have_pystring_asstr

Displaying 20 results from an estimated 29 matches for "have_pystring_asstr".

2017 May 09
1
[PATCH v2] python: add simple wrappers for PyObject<->string functions
...size_t size); +extern char *guestfs_int_py_asstring (PyObject *obj); "; @@ -178,31 +181,16 @@ and generate_python_structs () = function | name, FString -> pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; - pr "#else\n"; - pr " PyUnicode_FromString (%s->%s));\n" - typ name; - pr "#...
2017 May 09
0
[PATCH] python: add simple wrappers for PyObject<->string functions
...size_t size); +extern char *guestfs_int_py_asstring (PyObject *obj); "; @@ -178,31 +181,16 @@ and generate_python_structs () = function | name, FString -> pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; - pr "#else\n"; - pr " PyUnicode_FromString (%s->%s));\n" - typ name; - pr "#...
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
2017 Mar 18
0
[PATCH] python: check return value of Python APIs
...ntimeError, \"PyDict_New\");\n"; + pr " return NULL;\n"; + pr " }\n"; List.iter ( function | name, FString -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; + pr " value = PyString_FromString (%s->%s);\n" typ name; pr "#else\n"; - pr " PyUnicod...
2014 Jan 15
0
[PATCH 3/4] hivex: python: Produce Unicode strings in get_* methods
...tions(-) diff --git a/generator/generator.ml b/generator/generator.ml index 1f2690d..908c5f3 100755 --- a/generator/generator.ml +++ b/generator/generator.ml @@ -2925,11 +2925,7 @@ put_string_list (char * const * const argv) list = PyList_New (argc); for (i = 0; i < argc; ++i) { -#ifdef HAVE_PYSTRING_ASSTRING - PyList_SetItem (list, i, PyString_FromString (argv[i])); -#else - PyList_SetItem (list, i, PyUnicode_FromString (argv[i])); -#endif + PyList_SetItem (list, i, PyUnicode_DecodeUTF8 (argv[i], strlen (argv[i]), NULL)); } return list; @@ -2985,11 +2981,7 @@ put_val_type (char *val...
2017 Apr 25
1
[Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
...ntimeError, \"PyDict_New\");\n"; + pr " return NULL;\n"; + pr " }\n"; List.iter ( function | name, FString -> - pr " PyDict_SetItemString (dict, \"%s\",\n" name; pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; - pr " PyString_FromString (%s->%s));\n" - typ name; + pr " value = PyString_FromString (%s->%s);\n" typ name; pr "#else\n"; - pr " PyUnicod...
2014 Aug 08
2
[PATCH 1/2] Add type checking, support integers as value
...t; != "xno"], [AC_DEFINE([HAVE_PYCAPSULE_NEW],1, [Found PyCapsule_New in libpython])], [],[$PYTHON_BLDLIBRARY]) - AC_CHECK_LIB([c],[PyString_AsString], - [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1, - [Found PyString_AsString in libpython])], - [],[$PYTHON_BLDLIBRARY]) LIBS="$old_LIBS" fi diff --git a/generator/generator.ml b/generator/generator.ml index bcf1966..0aeb24e 100755 --- a/generator/g...
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
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
2015 Feb 14
0
[PATCH] python: Call PyErr_Clear() on non-error paths out of the Python bindings.
...pr " py_r = PyUnicode_FromString (r);\n"; - pr "#endif\n" + pr "#endif\n"; + pr " if (py_r == NULL) goto out;\n"; | RConstOptString _ -> pr " if (r) {\n"; pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; @@ -466,14 +467,16 @@ put_table (char * const * const argv) pr " } else {\n"; pr " Py_INCREF (Py_None);\n"; pr " py_r = Py_None;\n"; - pr " }\n" + pr " }\n"; + pr...
2016 Apr 01
1
[PATCH] python: Fix bug in code generator
...le changed, 4 insertions(+), 2 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index 9663fb4..9d9dc4a 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -225,10 +225,12 @@ put_table (char * const * const argv) | name, FChar -> pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyString_FromStringAndSize (&dirent->%s, 1));\n" name; + pr " PyString_FromStringAndSize (&%s->%s,...
2014 Nov 04
1
Re: [PATCH 7/9] python: fix detection of libpython features
...AC_DEFINE([HAVE_PYCAPSULE_NEW],1, > [Found PyCapsule_New in libpython.])], > - [],[$PYTHON_BLDLIBRARY]) > + [],[$PYTHON_LIBS]) > AC_CHECK_LIB([c],[PyString_AsString], > [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1, > [Found PyString_AsString in libpython.])], > - [],[$PYTHON_BLDLIBRARY]) > - > - LIBS="$old_LIBS" > + [],[$PYTHON_LIBS]) > fi > > AC_SUBST(PYTHON_PREFIX) > -- &g...
2017 May 21
0
[PATCH 2/2] python: unicode decode handler error scheme setter
...et_decode_error_handler", &decode_error_handler)) + return NULL; + + return guestfs_int_py_fromstring (previous_handler); +} + +PyObject * guestfs_int_py_create (PyObject *self, PyObject *args) { guestfs_h *g; @@ -386,7 +399,8 @@ guestfs_int_py_fromstring (const char *str) #ifdef HAVE_PYSTRING_ASSTRING return PyString_FromString (str); #else - return PyUnicode_FromString (str); + Py_ssize_t size = strlen(str); + return PyUnicode_DecodeUTF8 (str, size, decode_error_handler); #endif } @@ -396,7 +410,7 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) #ifdef HAVE_PYSTRING...
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 Sep 11
0
[PATCH nbdkit] python: Drop support for Python 2.
...uot;` - AC_CHECK_LIB([c],[PyString_FromString], - [AC_DEFINE([HAVE_PYSTRING_FROMSTRING],1, - [Found PyString_FromString in libpython.])], - [],[$PYTHON_BLDLIBRARY]) - AC_CHECK_LIB([c],[PyString_AsString], - [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1, - [Found PyString_AsString in libpython.])], - [],[$PYTHON_BLDLIBRARY]) - AC_CHECK_LIB([c],[PyUnicode_AsUTF8], - [AC_DEFINE([HAVE_PYUNICODE_ASUTF8],1, - [Found PyUnicode_AsUTF8 in libpython.])], -...
2018 Apr 05
0
[PATCH nbdkit] python: Turn python exceptions into nbdkit errors properly.
..."x$enable_python" != "xno"],[ [AC_DEFINE([HAVE_PYSTRING_FROMSTRING],1, [Found PyString_FromString in libpython.])], [],[$PYTHON_BLDLIBRARY]) + AC_CHECK_LIB([c],[PyString_AsString], + [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1, + [Found PyString_AsString in libpython.])], + [],[$PYTHON_BLDLIBRARY]) + AC_CHECK_LIB([c],[PyUnicode_AsUTF8], + [AC_DEFINE([HAVE_PYUNICODE_ASUTF8],1, + [Found PyUnicode_AsUTF8 in libpython.])], +...
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
2019 Sep 11
3
[PATCH nbdkit] python: Drop support for Python 2.
This patch proposes to drop support for Python 2 in nbdkit. Rather than abruptly drop it everywhere, my proposal is that we point people to nbdkit 1.14 (the current stable version) if they want to continue with Python 2 plugins, while gently reminding them of the upcoming Python 2.7 end of life announcement. Libnbd never supported Python 2. Libguestfs in theory supports Python 2 but I dropped
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 = {
2018 Apr 05
4
[PATCH nbdkit] python: Turn python exceptions into nbdkit errors
Much more annoying that it needs to be, but I have tested it and it works on Python 2 & 3. Note this will not work on Python 3.0 - 3.2, but I guess we don't care about those versions. Rich.