kihashi / mtg-irc

A module for the IRC Bot Phenny that allows users to query magic cards.
3 stars 1 forks source link

mtgotraders print statements error in Willie #58

Closed kihashi closed 9 years ago

kihashi commented 9 years ago

When updating prices from the bot, there is a unicode error. I think it is caused by the print statements in the module. Willie tries to log all of them to a file, but I am not encoding them at all, so it blows up when trying to decode them.

Traceback (most recent call last):
  File "/Users/john/willie/willie/bot.py", line 728, in call
    exit_code = func(willie, trigger)
  File "/Users/john/willie/willie/modules/mtg.py", line 29, in eprice
    mtgotraders.main()
  File "/Users/john/willie/willie/modules/mtgotraders.py", line 65, in main
    parse_list(get_raw_list(config.mtgotraders_api_url))
  File "/Users/john/willie/willie/modules/mtgotraders.py", line 49, in parse_list
    print line
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 352, in write
    self.stream.write(data)
  File "/Users/john/willie/willie/tools.py", line 329, in write
    logfile.write(string.encode('utf8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128)