summaryrefslogtreecommitdiff
path: root/src/logger.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-12-15 23:34:28 +0100
committermathieui <mathieui@mathieui.net>2012-12-15 23:34:28 +0100
commit344e8c8d6c1fc0fb6d03d2500d88f918fd4d46a8 (patch)
tree2b33d45b1f8579b6ef4f8e659cfe63e9ac74efe3 /src/logger.py
parent423bae05b0ce47607569acdb0d36cd048f96c8f8 (diff)
downloadpoezio-344e8c8d6c1fc0fb6d03d2500d88f918fd4d46a8.tar.gz
poezio-344e8c8d6c1fc0fb6d03d2500d88f918fd4d46a8.tar.bz2
poezio-344e8c8d6c1fc0fb6d03d2500d88f918fd4d46a8.tar.xz
poezio-344e8c8d6c1fc0fb6d03d2500d88f918fd4d46a8.zip
fix a traceback when we accidentally seek() in the middle of a char
Diffstat (limited to 'src/logger.py')
-rw-r--r--src/logger.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/logger.py b/src/logger.py
index da1aa09b..ae2e7a55 100644
--- a/src/logger.py
+++ b/src/logger.py
@@ -81,15 +81,19 @@ class Logger(object):
return
pos = fd.seek(0, 2)
- while len(fd.readlines()) < nb + 1:
+ reads = fd.readlines()
+ while len(reads) < nb + 1:
pos -= 100
if pos < 0:
break
fd.seek(pos)
- fd.seek(pos)
- logs = fd.readlines()
+ try:
+ reads = fd.readlines()
+ except UnicodeDecodeError:
+ pass
fd.close()
- return logs[-nb:]
+ logs = reads[-nb:]
+ return logs
def log_message(self, jid, nick, msg):
"""