Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-03-09 14:24:50 (GMT)
committer Jonas Smedegaard <dr@jones.dk>2008-03-09 14:24:50 (GMT)
commitde57007b544fab03df23f0fab3fc96e71115ab2d (patch)
tree81ed2ef388f7b55a2ed2726977ff47682ed4b070
parente2d710066fc6f3eff95f455ce560a75c28688804 (diff)
* Patch converter, datatore and backingstore to wrap try-except in
another try when using finally, to support Python 2.4.
-rw-r--r--debian/changelog7
-rw-r--r--src/olpc/datastore/backingstore.py7
-rw-r--r--src/olpc/datastore/converter.py23
-rw-r--r--src/olpc/datastore/datastore.py11
4 files changed, 29 insertions, 19 deletions
diff --git a/debian/changelog b/debian/changelog
index ac45a1f..a3e3276 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+sugar-datastore (0.8.0~git.13d354b-2) unstable; urgency=low
+
+ * Patch converter, datatore and backingstore to wrap try-except in
+ another try when using finally, to support Python 2.4.
+
+ -- Jonas Smedegaard <dr@jones.dk> Sun, 09 Mar 2008 15:22:55 +0100
+
sugar-datastore (0.8.0~git.13d354b-1) unstable; urgency=low
* Initial release. Closes: bug#444021.
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py
index fc3c05f..408c094 100644
--- a/src/olpc/datastore/backingstore.py
+++ b/src/olpc/datastore/backingstore.py
@@ -258,9 +258,10 @@ class FileBackingStore(BackingStore):
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()
diff --git a/src/olpc/datastore/converter.py b/src/olpc/datastore/converter.py
index 75f7568..e739f22 100644
--- a/src/olpc/datastore/converter.py
+++ b/src/olpc/datastore/converter.py
@@ -74,17 +74,18 @@ class subprocessconverter(object):
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
diff --git a/src/olpc/datastore/datastore.py b/src/olpc/datastore/datastore.py
index 67ddca9..736c1b9 100644
--- a/src/olpc/datastore/datastore.py
+++ b/src/olpc/datastore/datastore.py
@@ -412,11 +412,12 @@ class DataStore(dbus.service.Object):
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