GNOME Bugzilla – Bug 744745
GStrv property doesn't allow unicode items on Python 2
Last modified: 2015-07-17 15:44:57 UTC
test, since I hit bug 744491
Now the real thing: Passing unicode doesn't work for properties but works in Python3 and for callables. >>> from gi.repository import GUdev >>> GUdev.Client(subsystems=[u'block']) Traceback (most recent call last):
+ Trace 234686
>>>
Created attachment 297133 [details] [review] Allow passing unicode lists to GStrv properties on Python 2
Review of attachment 297133 [details] [review]: Overall this looks fine, just a quick question and some style nit picks. Thanks! ::: gi/pygi-value.c @@ +941,3 @@ + for (i = 0; i < argc; ++i) { + PyObject* item = PySequence_Fast_GET_ITEM (obj, i); + /* same as _pygi_marshal_from_py_utf8 */ Would it make sense to refactor and share code in both places? @@ +944,3 @@ + if(PyUnicode_Check (item)) { + PyObject *pystr_obj = PyUnicode_AsUTF8String (item); + if (!pystr_obj) Please use 1TBS @@ +954,3 @@ + } +#endif + goto error; 1TBS @@ +963,3 @@ + +error: + for (i = i - 1; i >= 0; i--) 1TBS
(In reply to Simon Feltman from comment #3) > Review of attachment 297133 [details] [review] [review]: > > Overall this looks fine, just a quick question and some style nit picks. > Thanks! > > ::: gi/pygi-value.c > @@ +941,3 @@ > + for (i = 0; i < argc; ++i) { > + PyObject* item = PySequence_Fast_GET_ITEM (obj, i); > + /* same as _pygi_marshal_from_py_utf8 */ > > Would it make sense to refactor and share code in both places? The error/exception handling is a bit different, but yeah I can look into that. Any suggestion were to best put such a helper?
Created attachment 298332 [details] [review] patch-v2 Updated patch only addressing the style issues.
Review of attachment 298332 [details] [review]: Looks good. Please commit with rebase and minor style issue nit. ::: gi/pygi-value.c @@ +942,3 @@ + PyObject* item = PySequence_Fast_GET_ITEM (obj, i); + /* same as _pygi_marshal_from_py_utf8 */ + if(PyUnicode_Check (item)) { space after "if"
Thanks