GNOME Bugzilla – Bug 764457
UnicodeDecodeError with non-UTF-8 filenames
Last modified: 2016-04-01 12:12:00 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.
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):
+ Trace 236135
*** This bug has been marked as a duplicate of bug 746564 ***