Displaying 11 results from an estimated 11 matches for "pyunicode_decode".
2020 Apr 20
4
[PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...a/python/handle.c b/python/handle.c
index 2fb8c18f0..427424707 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -387,7 +387,7 @@ guestfs_int_py_fromstring (const char *str)
#if PY_MAJOR_VERSION < 3
return PyString_FromString (str);
#else
- return PyUnicode_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...
2020 Apr 26
5
[PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...,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
0
Re: [PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...ex 2fb8c18f0..427424707 100644
> --- a/python/handle.c
> +++ b/python/handle.c
> @@ -387,7 +387,7 @@ guestfs_int_py_fromstring (const char *str)
> #if PY_MAJOR_VERSION < 3
> return PyString_FromString (str);
> #else
> - return PyUnicode_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_...
2020 Apr 23
0
Re: [PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...ex 2fb8c18f0..427424707 100644
> --- a/python/handle.c
> +++ b/python/handle.c
> @@ -387,7 +387,7 @@ guestfs_int_py_fromstring (const char *str)
> #if PY_MAJOR_VERSION < 3
> return PyString_FromString (str);
> #else
> - return PyUnicode_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_Fr...
2020 Apr 25
1
Re: [PATCH v2] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...--- a/python/handle.c
> > +++ b/python/handle.c
> > @@ -387,7 +387,7 @@ guestfs_int_py_fromstring (const char *str)
> > #if PY_MAJOR_VERSION < 3
> > return PyString_FromString (str);
> > #else
> > - return PyUnicode_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);
>...
2020 Jun 30
3
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...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 any error we can check as a way to detect this
> situation, rather than always attempting to decode it as latin1?
>
> T...
2020 Jun 03
2
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...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 merging this?
>
> Rich.
>
> --
> Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/...
2020 May 13
0
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...nst 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 merging this?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog...
2020 Jun 30
0
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...nst 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 any error we can check as a way to detect this
situation, rather than always attempting to decode it as latin1?
Thanks,
--
Pino Toscano
2020 Jun 30
0
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
...; > 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 merging this?
> >
> > Rich.
> >
> > --
> > Richard Jones,...
2020 Jul 06
1
Re: [PATCH v3] python: Fix UnicodeError in inspect_list_applications2() (RHBZ#1684004)
Hi Sam,
I was doing some work on the Python bindings, starting with removing
support for Python 2 since it's EOL. I thought I would have a look at
this patch.
So firstly I think the last version posted is:
https://www.redhat.com/archives/libguestfs/2020-April/msg00190.html
My impression of this is that we shouldn't just hack the Python
bindings to make this apparently work. But I