After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 744745 - GStrv property doesn't allow unicode items on Python 2
GStrv property doesn't allow unicode items on Python 2
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
Git master
Other Linux
: Normal minor
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-18 18:27 UTC by Christoph Reiter (lazka)
Modified: 2015-07-17 15:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow passing unicode lists to GStrv properties on Python 2 (2.94 KB, patch)
2015-02-18 18:35 UTC, Christoph Reiter (lazka)
none Details | Review
patch-v2 (3.03 KB, patch)
2015-03-02 17:06 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Christoph Reiter (lazka) 2015-02-18 18:27:32 UTC
test, since I hit bug 744491
Comment 1 Christoph Reiter (lazka) 2015-02-18 18:28:26 UTC
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):
  • File "<stdin>", line 1 in <module>
TypeError: could not convert value for property `subsystems' from list to GStrv
>>>
Comment 2 Christoph Reiter (lazka) 2015-02-18 18:35:27 UTC
Created attachment 297133 [details] [review]
Allow passing unicode lists to GStrv properties on Python 2
Comment 3 Simon Feltman 2015-03-01 05:00:28 UTC
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
Comment 4 Christoph Reiter (lazka) 2015-03-02 17:06:00 UTC
(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?
Comment 5 Christoph Reiter (lazka) 2015-03-02 17:06:49 UTC
Created attachment 298332 [details] [review]
patch-v2

Updated patch only addressing the style issues.
Comment 6 Simon Feltman 2015-07-17 05:18:37 UTC
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"
Comment 7 Christoph Reiter (lazka) 2015-07-17 15:44:57 UTC
Thanks