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 764457 - UnicodeDecodeError with non-UTF-8 filenames
UnicodeDecodeError with non-UTF-8 filenames
Status: RESOLVED DUPLICATE of bug 746564
Product: pygobject
Classification: Bindings
Component: gio
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2016-04-01 10:14 UTC by Dennis Tomas
Modified: 2016-04-01 12:12 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dennis Tomas 2016-04-01 10:14:06 UTC
In Python3, Gio.FileInfo.get_name() raises a UnicodeDecodeError for non-UTF-8 filenames. This is odd, because attribute Gio.FILE_ATTRIBUTE_STANDARD_NAME is supposed to be of type Gio.FileAttributeType.BYTE_STRING. In fact, Gio.FileInfo.get_name() (and Gio.FileInfo.get_attribute_byte_string() as well) always returns str objects, not bytes objects.
Comment 1 Dennis Tomas 2016-04-01 10:14:28 UTC
Steps to reproduce:

>>> from gi.repository import Gio
>>> import os
>>> os.makedirs(b'\xf6')
>>> directory = Gio.File.new_for_path('.')
>>> for file_info in directory.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_NAME, 0, None):
>>>   print(file_info.get_name())
[...]
Traceback (most recent call last):
  • File "<stdin>", line 2 in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 0: invalid start byte

Comment 2 Christoph Reiter (lazka) 2016-04-01 12:12:00 UTC

*** This bug has been marked as a duplicate of bug 746564 ***