Mercurial > cpython-lru_cache-weakref
diff Lib/lib-tk/tkFileDialog.py @ 21596:5ff8bb25031c legacy-trunk
Print encoded versions of the file names in test application. Fixes #496084
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sun, 30 Dec 2001 14:43:56 +0000 |
| parents | 20014716556b |
| children | 3c8a9ef3b954 |
line wrap: on
line diff
--- a/Lib/lib-tk/tkFileDialog.py Sat Dec 29 17:34:57 2001 +0000 +++ b/Lib/lib-tk/tkFileDialog.py Sun Dec 30 14:43:56 2001 +0000 @@ -124,6 +124,20 @@ # 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. - print "open", askopenfilename(filetypes=[("all filez", "*")]) - print "saveas", asksaveasfilename() + # 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) +
