From 80a89d39314da44a8800cb6c6db8b616b4d0ff21 Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Tue, 8 Jun 2010 18:33:02 -0700
Subject: [PATCH] stringutils.py, sftpd.py: Portability fixes for Python <=
 2.5.

---
 src/allmydata/frontends/sftpd.py  | 2 +-
 src/allmydata/util/stringutils.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/allmydata/frontends/sftpd.py b/src/allmydata/frontends/sftpd.py
index 5d54962b..975b6c4d 100644
--- a/src/allmydata/frontends/sftpd.py
+++ b/src/allmydata/frontends/sftpd.py
@@ -311,7 +311,7 @@ class EncryptedTemporaryFile(PrefixingLogMixin):
     def flush(self):
         self.file.flush()
 
-    def seek(self, offset, whence=os.SEEK_SET):
+    def seek(self, offset, whence=0):  # 0 = SEEK_SET
         if noisy: self.log(".seek(%r, %r)" % (offset, whence), level=NOISY)
         self.file.seek(offset, whence)
 
diff --git a/src/allmydata/util/stringutils.py b/src/allmydata/util/stringutils.py
index d5c20865..bce2868d 100644
--- a/src/allmydata/util/stringutils.py
+++ b/src/allmydata/util/stringutils.py
@@ -25,7 +25,7 @@ def _canonical_encoding(encoding):
     # fail early if this happens
     try:
         u"test".encode(encoding)
-    except LookupError:
+    except (LookupError, AttributeError):
         raise AssertionError("The character encoding '%s' is not supported for conversion." % (encoding,))
 
     return encoding
-- 
2.45.2