diff options
Diffstat (limited to 'debian/patches/1002_avoid_try-except-finally.patch')
-rw-r--r-- | debian/patches/1002_avoid_try-except-finally.patch | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/debian/patches/1002_avoid_try-except-finally.patch b/debian/patches/1002_avoid_try-except-finally.patch new file mode 100644 index 0000000..8fe7bb8 --- /dev/null +++ b/debian/patches/1002_avoid_try-except-finally.patch @@ -0,0 +1,68 @@ +--- sugar-datastore-0.8.0~git.13d354b.orig/src/olpc/datastore/backingstore.py ++++ sugar-datastore-0.8.0~git.13d354b/src/olpc/datastore/backingstore.py +@@ -269,9 +269,10 @@ + if os.path.exists(fn): + fp = open(fn, 'r') + try: +- desc = pickle.load(fp) +- except: +- desc = {} ++ try: ++ desc = pickle.load(fp) ++ except: ++ desc = {} + finally: + fp.close() + +--- sugar-datastore-0.8.0~git.13d354b.orig/src/olpc/datastore/converter.py ++++ sugar-datastore-0.8.0~git.13d354b/src/olpc/datastore/converter.py +@@ -74,17 +74,18 @@ + cmd = self.raw % data + + try: +- cmd = cmd.split() +- # the stderr capture here will hide glib error messages +- # from converters which shouldn't be generating output anyway +- retcode = subprocess.call(cmd, stderr=subprocess.PIPE) +- if retcode: return None +- return codecs.open(target, 'r', 'utf-8') +- except UnicodeDecodeError: +- # The data was an unknown type but couldn't be understood +- # as text so we don't attempt to index it. This most +- # likely means its just an unknown binary format. +- return None ++ try: ++ cmd = cmd.split() ++ # the stderr capture here will hide glib error messages ++ # from converters which shouldn't be generating output anyway ++ retcode = subprocess.call(cmd, stderr=subprocess.PIPE) ++ if retcode: return None ++ return codecs.open(target, 'r', 'utf-8') ++ except UnicodeDecodeError: ++ # The data was an unknown type but couldn't be understood ++ # as text so we don't attempt to index it. This most ++ # likely means its just an unknown binary format. ++ return None + finally: + # we unlink the file as its already been opened for + # reading +--- sugar-datastore-0.8.0~git.13d354b.orig/src/olpc/datastore/datastore.py ++++ sugar-datastore-0.8.0~git.13d354b/src/olpc/datastore/datastore.py +@@ -394,11 +394,12 @@ + backingstore = content.backingstore + backingstore.current_user_id = dbus.Bus().get_unix_user(sender) + try: +- # Retrieving the file path for the file will cause the file to be +- # copied or linked to a directory accessible by the caller. +- file_path = content.filename +- except AttributeError: +- file_path = '' ++ try: ++ # Retrieving the file path for the file will cause the file to be ++ # copied or linked to a directory accessible by the caller. ++ file_path = content.filename ++ except AttributeError: ++ file_path = '' + finally: + backingstore.current_user_id = None + return file_path |