Skip to content

Commit

Permalink
Replace open-try-finally with 'with open'
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed Aug 20, 2014
1 parent 383ce6c commit ac31af9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions rsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ def close(self):
def send_save(self):
self.socket.send(b"save\n")
self.socket.send(b"token: " + self.env['token'].encode("utf8") + b"\n")
temp_file = open(self.temp_path, "rb")
new_file = temp_file.read()
temp_file.close()
with open(self.temp_path, 'rb') as f:
new_file = f.read()
self.socket.send(b"data: " + str(len(new_file)).encode("utf8") + b"\n")
self.socket.send(new_file)
self.socket.send(b"\n")
Expand Down

0 comments on commit ac31af9

Please sign in to comment.