From 36aab63dac88d33d7ddb282b0cb3bcd3dec7b8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 31 Aug 2016 22:55:03 +0200 Subject: [PATCH] Convert file names from gtk.FileChooserDialog On POSIX, it is encoded using the file system encoding. On Windows, it is always UTF-8. See http://www.pygtk.org/pygtk2reference/class-gtkfilechooser.html#FileNamesAndEncodings issue5671 review21231002 --- tryton/common/common.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tryton/common/common.py b/tryton/common/common.py index 4c094a8538..7646aeffc4 100644 --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -423,13 +423,19 @@ def file_selection(title, filename='', win.set_preview_widget(img_preview) win.connect('update-preview', update_preview_cb, img_preview) + if os.name == 'nt': + encoding = 'utf-8' + else: + encoding = sys.getfilesystemencoding() button = win.run() if button != gtk.RESPONSE_OK: - result = False + result = None elif not multi: result = win.get_filename() + if result: + result = unicode(result, encoding) else: - result = win.get_filenames() + result = [unicode(path, encoding) for path in win.get_filenames()] parent.present() win.destroy() return result