From ec6b85a75b7fa6a90fa1cc7fd80e5a3640e6395f Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Thu, 3 Jan 2013 17:09:51 +0400 Subject: [PATCH] close file automaticaly --- src/profile_window.py | 4 ++-- src/remote_control.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/profile_window.py b/src/profile_window.py index a56911cc2..868639590 100644 --- a/src/profile_window.py +++ b/src/profile_window.py @@ -154,8 +154,8 @@ class ProfileWindow: scaled_pixbuf.savev(path_to_file, 'png', [], []) must_delete = True - fd = open(path_to_file, 'rb') - data = fd.read() + with open(path_to_file, 'rb') as fd: + data = fd.read() pixbuf = gtkgui_helpers.get_pixbuf_from_data(data) try: # rescale it diff --git a/src/remote_control.py b/src/remote_control.py index 4f9e97300..da7e50015 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -905,8 +905,8 @@ class SignalObject(dbus.service.Object): else: invalid_file = True if not invalid_file and filesize < 16384: - fd = open(picture, 'rb') - data = fd.read() + with open(picture, 'rb') as fb: + data = fd.read() avatar = base64.b64encode(data).decode('utf-8') avatar_mime_type = mimetypes.guess_type(picture)[0] vcard={}