search for: pyunicode_fromstringandsize

Displaying 20 results from an estimated 25 matches for "pyunicode_fromstringandsize".

2016 Apr 01
1
[PATCH] python: Fix bug in code generator
...ame; + pr " PyString_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr "#else\n"; pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyUnicode_FromStringAndSize (&dirent->%s, 1));\n" name; + pr " PyUnicode_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr "#endif\n" ) cols; pr " return dict;\n"; -- 2.8.0.rc3
2020 Apr 26
5
[PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...); #else - return PyUnicode_FromString (str); + return guestfs_int_py_fromstringsize (str, strlen (str)); #endif } @@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) #if PY_MAJOR_VERSION < 3 return PyString_FromStringAndSize (str, size); #else - return PyUnicode_FromStringAndSize (str, size); + PyObject *s = PyUnicode_FromString (str); + if (s == NULL) { + PyErr_Clear (); + s = PyUnicode_Decode (str, strlen(str), "latin1", "strict"); + } + return s; #endif } -- 2.26.2.303.gf8c07b1a785-goog
2020 Apr 20
4
[PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...icode_FromString (str); + return PyUnicode_Decode(str, strlen(str), "utf-8", "replace"); #endif } @@ -397,7 +397,7 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) #if PY_MAJOR_VERSION < 3 return PyString_FromStringAndSize (str, size); #else - return PyUnicode_FromStringAndSize (str, size); + return PyUnicode_Decode(str, size, "utf-8", "replace"); #endif } -- 2.26.1.301.g55bc3eb7cb9-goog
2016 Apr 01
0
[PATCH] python: Fix bug in code generator
...ame; + pr " PyString_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr "#else\n"; pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyUnicode_FromStringAndSize (&dirent->%s, 1));\n" name; + pr " PyUnicode_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr "#endif\n" ) cols; pr " return dict;\n"; -- 2.8.0.rc3
2020 Jun 30
3
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...size (str, strlen (str)); > > #endif > > } > > > > @@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, > size_t size) > > #if PY_MAJOR_VERSION < 3 > > return PyString_FromStringAndSize (str, size); > > #else > > - return PyUnicode_FromStringAndSize (str, size); > > + PyObject *s = PyUnicode_FromString (str); > > + if (s == NULL) { > > + PyErr_Clear (); > > + s = PyUnicode_Decode (str, strlen(str), "latin1", "strict"); > > Minor nit: space between "strlen" and the opening brac...
2020 Jun 03
2
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...tringsize (str, strlen (str)); > > #endif > > } > > > > @@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) > > #if PY_MAJOR_VERSION < 3 > > return PyString_FromStringAndSize (str, size); > > #else > > - return PyUnicode_FromStringAndSize (str, size); > > + PyObject *s = PyUnicode_FromString (str); > > + if (s == NULL) { > > + PyErr_Clear (); > > + s = PyUnicode_Decode (str, strlen(str), "latin1", "strict"); > > + } > > + return s; > > #endif > > } >...
2017 Mar 18
0
[PATCH] python: check return value of Python APIs
...;\n" - typ name; + pr " value = PyString_FromStringAndSize (&%s->%s, 1);\n" typ name; pr "#else\n"; - pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyUnicode_FromStringAndSize (&%s->%s, 1));\n" + pr " value = PyUnicode_FromStringAndSize (&%s->%s, 1);\n" typ name; - pr "#endif\n" + pr "#endif\n"; + pr " if (value == NULL) {\n"; + pr "...
2019 Jun 03
3
[PATCH libnbd] api: nbd_get_version, nbd_supports_uri and nbd_get_package_name.
...@@ free_aio_buffer (PyObject *capsule) free (buf); } -PyObject * -nbd_internal_py_get_package_name (PyObject *self, PyObject *args) -{ - static char name[] = PACKAGE_NAME; - - if (!PyArg_ParseTuple (args, (char *) ":nbd_internal_py_get_package_name")) - return NULL; - - return PyUnicode_FromStringAndSize (name, strlen (name)); -} - -PyObject * -nbd_internal_py_get_package_version (PyObject *self, PyObject *args) -{ - static char version[] = PACKAGE_VERSION; - - if (!PyArg_ParseTuple (args, (char *) ":nbd_internal_py_get_package_version")) - return NULL; - - return PyUnicode_FromStri...
2017 Apr 25
1
[Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
...;\n" - typ name; + pr " value = PyString_FromStringAndSize (&%s->%s, 1);\n" typ name; pr "#else\n"; - pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyUnicode_FromStringAndSize (&%s->%s, 1));\n" + pr " value = PyUnicode_FromStringAndSize (&%s->%s, 1);\n" typ name; - pr "#endif\n" + pr "#endif\n"; + pr " if (value == NULL) {\n"; + pr "...
2018 Jan 30
0
Re: python 3 bindings on libguestfs
...and if you compare that to the code, eg in python/guestfs-py.c: #ifdef HAVE_PYSTRING_ASSTRING PyDict_SetItemString (dict, "ftyp", PyString_FromStringAndSize (&dirent->ftyp, 1)); #else PyDict_SetItemString (dict, "ftyp", PyUnicode_FromStringAndSize (&dirent->ftyp, 1)); #endif So it shouldn't be using that function (PyString_FromStringAndSize) at all. I think most likely you've either attached the wrong log, or it's loading libguestfsmod.so from another build of libguestfs (eg. one linked with Python 2) so it might be you...
2020 Apr 20
0
Re: [PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...ode_Decode(str, strlen(str), "utf-8", "replace"); > #endif > } > > @@ -397,7 +397,7 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) > #if PY_MAJOR_VERSION < 3 > return PyString_FromStringAndSize (str, size); > #else > - return PyUnicode_FromStringAndSize (str, size); > + return PyUnicode_Decode(str, size, "utf-8", "replace"); > #endif > } Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.o...
2020 Apr 23
0
Re: [PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...icode_Decode(str, strlen(str), "utf-8", "replace"); > #endif > } > > @@ -397,7 +397,7 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) > #if PY_MAJOR_VERSION < 3 > return PyString_FromStringAndSize (str, size); > #else > - return PyUnicode_FromStringAndSize (str, size); > + return PyUnicode_Decode(str, size, "utf-8", "replace"); > #endif > } > > -- > 2.26.1.301.g55bc3eb7cb9-goog > > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://ww...
2020 May 13
0
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...); > + return guestfs_int_py_fromstringsize (str, strlen (str)); > #endif > } > > @@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) > #if PY_MAJOR_VERSION < 3 > return PyString_FromStringAndSize (str, size); > #else > - return PyUnicode_FromStringAndSize (str, size); > + PyObject *s = PyUnicode_FromString (str); > + if (s == NULL) { > + PyErr_Clear (); > + s = PyUnicode_Decode (str, strlen(str), "latin1", "strict"); > + } > + return s; > #endif > } Looks OK to me. Pino - any objections to me...
2020 Jun 30
0
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...); > + return guestfs_int_py_fromstringsize (str, strlen (str)); > #endif > } > > @@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, size_t size) > #if PY_MAJOR_VERSION < 3 > return PyString_FromStringAndSize (str, size); > #else > - return PyUnicode_FromStringAndSize (str, size); > + PyObject *s = PyUnicode_FromString (str); > + if (s == NULL) { > + PyErr_Clear (); > + s = PyUnicode_Decode (str, strlen(str), "latin1", "strict"); Minor nit: space between "strlen" and the opening bracket. Also, isn't there a...
2014 Jan 15
0
[PATCH 3/4] hivex: python: Produce Unicode strings in get_* methods
...if f_len_exists name then - pr " py_r = PyString_FromStringAndSize (r, sz);\n" - else - pr " py_r = PyString_FromString (r);\n"; - pr "#else\n"; if f_len_exists name then - pr " py_r = PyUnicode_FromStringAndSize (r, sz);\n" + pr " py_r = PyUnicode_DecodeUTF8 (r, sz, NULL);\n" else - pr " py_r = PyUnicode_FromString (r);\n"; - pr "#endif\n"; + pr " py_r = PyUnicode_DecodeUTF8 (r, strlen (r), NULL);\n";...
2020 Jun 30
0
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...#endif > > > } > > > > > > @@ -397,7 +397,12 @@ guestfs_int_py_fromstringsize (const char *str, > size_t size) > > > #if PY_MAJOR_VERSION < 3 > > > return PyString_FromStringAndSize (str, size); > > > #else > > > - return PyUnicode_FromStringAndSize (str, size); > > > + PyObject *s = PyUnicode_FromString (str); > > > + if (s == NULL) { > > > + PyErr_Clear (); > > > + s = PyUnicode_Decode (str, strlen(str), "latin1", "strict"); > > > + } > > > + return s; > &...
2017 May 21
0
[PATCH 2/2] python: unicode decode handler error scheme setter
...g (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_ASSTRING return PyString_FromStringAndSize (str, size); #else - return PyUnicode_FromStringAndSize (str, size); + return PyUnicode_DecodeUTF8 (str, size, decode_error_handler); #endif } diff --git a/python/t/test830RHBZ1406906.py b/python/t/test830RHBZ1406906.py index 17b875226..0bb1ac1d0 100644 --- a/python/t/test830RHBZ1406906.py +++ b/python/t/test830RHBZ1406906.py @@ -55,3 +55,9 @@ class...
2017 May 09
1
[PATCH v2] python: add simple wrappers for PyObject<->string functions
...ame; - pr " PyString_FromStringAndSize (&%s->%s, 1));\n" - typ name; - pr "#else\n"; - pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyUnicode_FromStringAndSize (&%s->%s, 1));\n" - typ name; - pr "#endif\n" + pr " guestfs_int_py_fromstringsize (&%s->%s, 1));\n" + typ name ) cols; pr " return dict;\n"; pr "};\n&q...
2020 Apr 25
1
Re: [PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...ot;, "replace"); > > #endif > > } > > > > @@ -397,7 +397,7 @@ guestfs_int_py_fromstringsize (const char *str, > size_t size) > > #if PY_MAJOR_VERSION < 3 > > return PyString_FromStringAndSize (str, size); > > #else > > - return PyUnicode_FromStringAndSize (str, size); > > + return PyUnicode_Decode(str, size, "utf-8", "replace"); > > #endif > > } > > > > -- > > 2.26.1.301.g55bc3eb7cb9-goog > > > > > > _______________________________________________ > > Libguestfs maili...
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