Skip to content

Commit

Permalink
[tell] Fix Python 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Alfassa committed Jul 18, 2014
1 parent 1dd198a commit 5aae7c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tell.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import datetime
import willie.tools
import threading
import sys
from willie.tools import Nick, iterkeys
from willie.module import commands, nickname_commands, rule, priority, example

Expand All @@ -25,7 +26,9 @@ def loadReminders(fn, lock):
result = {}
f = open(fn)
for line in f:
line = line.strip().decode('utf8')
line = line.strip()
if sys.version_info.major < 3:
line = line.decode('utf-8')
if line:
try:
tellee, teller, verb, timenow, msg = line.split('\t', 4)
Expand All @@ -46,7 +49,10 @@ def dumpReminders(fn, data, lock):
for remindon in data[tellee]:
line = '\t'.join((tellee,) + remindon)
try:
f.write((line + '\n').encode('utf-8'))
to_write = line + '\n'
if sys.version_info.major < 3:
to_write = to_write.encode('utf-8')
f.write(to_write)
except IOError:
break
try:
Expand Down

0 comments on commit 5aae7c9

Please sign in to comment.