better use of pickle

This commit is contained in:
Brendan Taylor 2009-01-09 18:40:01 +00:00
parent bd759262bb
commit 02659358db
1 changed files with 2 additions and 4 deletions

View File

@ -42,10 +42,8 @@ class Secrets:
raise exceptions.Cancelled raise exceptions.Cancelled
def save(self): def save(self):
pickle.dumps(self)
f = open(secrets_filename, 'w') f = open(secrets_filename, 'w')
f.write(pickle.dumps(self)) pickle.dump(self, f)
f.close() f.close()
def retained_secrets(self, account, bare_jid): def retained_secrets(self, account, bare_jid):
@ -100,7 +98,7 @@ def load_secrets(filename):
f = open(filename, 'r') f = open(filename, 'r')
try: try:
secrets = pickle.loads(f.read()) secrets = pickle.load(f)
except KeyError: except KeyError:
f.close() f.close()
secrets = Secrets(filename) secrets = Secrets(filename)