Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#7 unicode in Python 2.7 breaks fileopen & filesave boxes

Python 2.7
open-accepted
Stephen Ferg
5
2012-03-25
2012-03-25
Stephen Ferg
No

On 11/21/2011 George Swinnerton wrote:

I found a problem with EasyGui 0.96 since changing from Python 2.5 to Python 2.7.

In my program, I use easygui.fileopenbox to obtain a source file, which is then used as the default file in the easygui.filesavebox.

In 2.5 the path is returned as a string but in 2.7 it is being returned as unicode.

This causes the comparison in line 1492 to fail.

if type(filemask) == type("abc"): # a string

Since the filemask was of type unicode (not of type string) this test was failing and causing an exception to be raised.

I've fixed the problem by changing the line to this:

if isinstance(filemask, str) or isinstance(filemask, unicode): # a string

which now works as expected.

Discussion

  • Stephen Ferg
    Stephen Ferg
    2012-03-25

    • milestone: --> Python 2.7
     
  • Stephen Ferg
    Stephen Ferg
    2012-03-25

    • status: open --> open-accepted