#7 unicode in Python 2.7 breaks fileopen & filesave boxes

v 0.97

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.


  • Stephen Ferg

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

    Stephen Ferg - 2012-03-25
    • status: open --> open-accepted
  • Robert Lugg

    Robert Lugg - 2014-11-16

    This will be changed to isinstance(filemask, basestring). There are other locations where a type()==type() check is performed. Changed them all as ininstance() is now the preferred paradigm.

    Last edit: Robert Lugg 2014-11-17
  • Robert Lugg

    Robert Lugg - 2014-11-18
    • Owner: Stephen Ferg --> Robert Lugg
    • Group: Python 2.7 --> v 0.97
  • Robert Lugg

    Robert Lugg - 2015-02-05
    • status: open-accepted --> fixed

Log in to post a comment.