From 95b1ea548042fa7370a5f943429e079ee976e772 Mon Sep 17 00:00:00 2001 From: AZ Huang Date: Thu, 20 Feb 2014 11:38:20 +0000 Subject: [PATCH] Fix bugs. --- tox-irc-sync.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tox-irc-sync.py b/tox-irc-sync.py index 5c53179..b7c9469 100644 --- a/tox-irc-sync.py +++ b/tox-irc-sync.py @@ -3,6 +3,7 @@ import socket import string import select import re +import pickle from tox import Tox @@ -37,7 +38,8 @@ class SyncBot(Tox): self.memory = {} if exists(MEMORY_DB): - self.memory = pickle.load(MEMORY_DB) + with open(MEMORY_DB, 'r') as f: + self.memory = pickle.load(f) def irc_init(self): self.irc = socket.socket() @@ -191,7 +193,8 @@ class SyncBot(Tox): subject = args[0] desc = ' '.join(args[1:]) self.memory[subject] = desc - pickle.dump(self.memory, MEMORY_DB) + with open(MEMORY_DB, 'w') as f: + pickle.dump(self.memory, f) self.send_both('Remembering ^%s: %s' % (subject, desc)) elif self.memory.has_key(cmd): self.send_both(self.memory[cmd])