summaryrefslogtreecommitdiffstats
path: root/Lib/lib-tk/tkFileDialog.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-12-30 14:43:56 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-12-30 14:43:56 (GMT)
commit85f98143b7860dbbe791535450e5c94b67cb1bc9 (patch)
tree92a89570ac433ec35019dd01b31b2e4bb686f00a /Lib/lib-tk/tkFileDialog.py
parent77902970c598c068a2916e86ca386d1387c4c369 (diff)
downloadcpython-85f98143b7860dbbe791535450e5c94b67cb1bc9.zip
cpython-85f98143b7860dbbe791535450e5c94b67cb1bc9.tar.gz
cpython-85f98143b7860dbbe791535450e5c94b67cb1bc9.tar.bz2
Print encoded versions of the file names in test application. Fixes #496084
Diffstat (limited to 'Lib/lib-tk/tkFileDialog.py')
-rw-r--r--Lib/lib-tk/tkFileDialog.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/Lib/lib-tk/tkFileDialog.py b/Lib/lib-tk/tkFileDialog.py
index 9d2af51..f2604bc 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()