This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ber
Recipients
Date 2002-04-04.18:59:22
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Patch is against current CVS form 20020404.
It also gives pointers to the problem described
in
http://mail.python.org/pipermail/python-list/2001-June/048787.html



Python's open() uses the Py_FileSystemDefaultEncoding.
Py_FileSystemDefaultEncoding is NULL (bltinmodule.c)
for most systems.
Setlocate will set it.  Thus we fixed the example and
set the locale to
the user defaults. Now "enc" will have a useful
encoding thus the
example will work with a non ascii characters in the
filename,
e.g. with umlauts in it.  It bombed on them before.

        Traceback (most recent call last):
  File "tkFileDialog.py", line 105, in ?
    print "open", askopenfilename(filetypes=[("all
filez", "*")])
  UnicodeError: ASCII encoding error: ordinal not in
range(128)

open() will work with the string directly now.
encode(enc) is only needed for terminal output,
thus we enchanced the example to show the two uses of
the returned filename
string separatly.

(It might be interesting to drop a note about this in
the right part of the user documentation.)

If you comment out the setlocale() you can see that
open fails,
which illustrates what seems to be a design flaw in tk.
Tk should be able to give you a string in exactly
the encoding in which the filesystem gave it to tk.


4.4.2002
Bernhard <bernhard@intevation.de>
Bernhard <bh@intevation.de>
History
Date User Action Args
2007-08-23 15:12:03adminlinkissue539392 messages
2007-08-23 15:12:03admincreate