bug concerning unicode encoding

Stefan Kloe stefan.kloe at googlemail.com
Thu Oct 11 09:06:43 EDT 2007


Hi,

yesterday I found pydance in the ubuntu feisty repository and fascinated
by DDR I installed it and played a little. After downloading some songs
I got an error and the program exits with an UnicodeEncodeError.

I checked out the trunk-version and got the same error. After looking
into the sources I found out that the problem was at the definition of
the SORTS methods in songselect.py. If I remove the str() method and
change the code from 

SORTS = {
  "subtitle": (lambda x, y: cmp(str(x.info["subtitle"]).lower(),
                                str(y.info["subtitle"]).lower())),
  "title": (lambda x, y: (cmp(x.info["title"].lower(),
                              y.info["title"].lower()) or
                          SORTS["subtitle"](x, y))),
  "artist": (lambda x, y: (cmp(x.info["artist"].lower(),
                               y.info["artist"].lower()) or
                           SORTS["title"](x, y))),
  "bpm": (lambda x, y: (cmp(x.info["bpm"], y.info["bpm"]) or
                        SORTS["title"](x, y))),
  "mix": (lambda x, y: (cmp(str(x.info["mix"]).lower(),
                            str(y.info["mix"]).lower()) or
                        SORTS["title"](x, y)))
  }

to 

SORTS = {
  "subtitle": (lambda x, y: (cmp(x.info["subtitle"].lower(),
                                y.info["subtitle"].lower()))),
  "title": (lambda x, y: (cmp(x.info["title"].lower(),
                              y.info["title"].lower()) or
                          SORTS["subtitle"](x, y))),
  "artist": (lambda x, y: (cmp(x.info["artist"].lower(),
                               y.info["artist"].lower()) or
                           SORTS["title"](x, y))),
  "bpm": (lambda x, y: (cmp(x.info["bpm"], y.info["bpm"]) or
                        SORTS["title"](x, y))),
  "mix": (lambda x, y: (cmp(x.info["mix"].lower(),
                            y.info["mix"].lower()) or
                        SORTS["title"](x, y)))
  }

everything works. The str() method should not be needed any longer
because you perform sanity checks at your parser.


PS:
Thank you for the great program. Yesterday I also ordered an adapter and
dance mat and am really excited to try them.




More information about the pyddr-discuss mailing list