From 85f98143b7860dbbe791535450e5c94b67cb1bc9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 30 Dec 2001 14:43:56 +0000 Subject: [PATCH] Print encoded versions of the file names in test application. Fixes #496084 --- Lib/lib-tk/tkFileDialog.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Lib/lib-tk/tkFileDialog.py b/Lib/lib-tk/tkFileDialog.py index 9d2af510c7..f2604bcf85 100644 --- a/Lib/lib-tk/tkFileDialog.py +++ b/Lib/lib-tk/tkFileDialog.py @@ -124,6 +124,20 @@ def askdirectory (**options): # test stuff if __name__ == "__main__": + # Since the file name may contain non-ASCII characters, we need + # to find an encoding that likely supports the file name, and + # displays correctly on the terminal. + + # Start off with UTF-8 + enc = "utf-8" + + # See whether CODESET is defined + try: + import locale + enc = locale.nl_langinfo(locale.CODESET) + except (ImportError, AttributeError): + pass + + print "open", askopenfilename(filetypes=[("all filez", "*")]).encode(enc) + print "saveas", asksaveasfilename().encode(enc) - print "open", askopenfilename(filetypes=[("all filez", "*")]) - print "saveas", asksaveasfilename() -- 2.50.1