-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing previews in Journal, and UnicodeWarning in log #16
Comments
Also occurs in Clock activity.
Does not occur in Read if run in Python 3. |
Reproduced by running Read in Python 2. Instrumented code with tracebacks. The warning occurs when the preview metadata is changed for the third time. The sequence of changes to preview are;
The warning happens when the updated signal is delivered after the activity has updated the preview metadata. The updated signal is handled by setting the data again, which is usually harmless because the data came from the activity itself. The warning happens because the binary data in preview could not be converted from dbus.String; with a UnicodeDecodeError, because the data contains byte sequences which are not Unicode. All other forms of metadata are textual. Only preview triggers this. |
The binary metadata for the preview returned by get_properties has a type of dbus.String instead of the expected type dbus.ByteArray. Using Looks like this happened in 6f4fcae ("Port to Python 3"). @pro-panda, it was about this time last year, but can you look at those lines and tell me why the metadata is being forced to string? |
May be the cause of missing previews in Journal. Detail view shows traceback;
|
That 6f4fcae ("Port to Python 3") commit is bad in that respect. The metadata was stored as bytes before, and there is a big comment about how it has to be stored as bytes and how, coincidentally, |
Thanks. I agree. I'll look at it in about four hours if nobody else does. |
From memory, All values are converted to
and ultimately returning strings of format "b'<string>'"
|
Seems like there should be no |
I agree with @mdengler 's comments. Py2 string handling was /mostly/ 8-bit clean, and Py3 string handling is most definitely not. IMHO datastore should not ever try to interpret them -- I'd remove all casts to string. Unfortunately I don't have a test env handy to run Sugar components (and I'm about to have to dodge a hurricane). I do have some recent/current Fedora systems. |
Previews were missing, on-disk metadata for previews was wrong data type, and UnicodeWarnings were in activity logs; UnicodeWarning: Unicode unequal comparison failed to convert both \ arguments to Unicode - interpreting them as being unequal if key not in self._properties or self._properties[key] != value: Convert any non-bytes metadata to bytes before writing to disk. Convert back to expected data type when reading from disk. Recognise specific keys and data types; all other values are dbus.String Regression introduced by 9e21c0a ("Port to Python 3"). Fixes #16
Preview metadata in 0.114 and earlier was returned by datastore client as a dbus.ByteArray. Regression introduced by aa8a5e7 ("Port from Python 2 to six"). Traceback (most recent call last): File "/usr/lib/python3.7/dist-packages/jarabe/journal/expandedentry.py", line 378, in _create_preview pixbuf = get_preview_pixbuf(metadata.get('preview', '')) File "/usr/lib/python3.7/dist-packages/sugar3/graphics/objectchooser.py", line 85, in get_preview_pixbuf preview_data = base64.b64decode(preview_data) File "/usr/lib/python3.7/base64.py", line 87, in b64decode return binascii.a2b_base64(s) binascii.Error: Invalid base64-encoded string: number of data characters (237) cannot be 1 more than a multiple of 4 Related to sugarlabs/sugar-datastore#16
Preview metadata in 0.114 and earlier was returned by datastore client as a dbus.ByteArray. Regression introduced by aa8a5e7 ("Port from Python 2 to six"). Traceback (most recent call last): File "/usr/lib/python3.7/dist-packages/jarabe/journal/expandedentry.py", line 378, in _create_preview pixbuf = get_preview_pixbuf(metadata.get('preview', '')) File "/usr/lib/python3.7/dist-packages/sugar3/graphics/objectchooser.py", line 85, in get_preview_pixbuf preview_data = base64.b64decode(preview_data) File "/usr/lib/python3.7/base64.py", line 87, in b64decode return binascii.a2b_base64(s) binascii.Error: Invalid base64-encoded string: number of data characters (237) cannot be 1 more than a multiple of 4 Related to sugarlabs/sugar-datastore#16
Think I've fixed it. |
Preview metadata in 0.114 and earlier was returned by datastore client as a dbus.ByteArray. Regression introduced by aa8a5e7 ("Port from Python 2 to six"). Traceback (most recent call last): File "/usr/lib/python3.7/dist-packages/jarabe/journal/expandedentry.py", line 378, in _create_preview pixbuf = get_preview_pixbuf(metadata.get('preview', '')) File "/usr/lib/python3.7/dist-packages/sugar3/graphics/objectchooser.py", line 85, in get_preview_pixbuf preview_data = base64.b64decode(preview_data) File "/usr/lib/python3.7/base64.py", line 87, in b64decode return binascii.a2b_base64(s) binascii.Error: Invalid base64-encoded string: number of data characters (237) cannot be 1 more than a multiple of 4 Related to sugarlabs/sugar-datastore#16
The text was updated successfully, but these errors were encountered: