From: david-sarah Date: Wed, 9 Jun 2010 01:33:02 +0000 (-0700) Subject: stringutils.py, sftpd.py: Portability fixes for Python <= 2.5. X-Git-Url: https://git.rkrishnan.org/%3C?a=commitdiff_plain;h=80a89d39314da44a8800cb6c6db8b616b4d0ff21;p=tahoe-lafs%2Ftahoe-lafs.git stringutils.py, sftpd.py: Portability fixes for Python <= 2.5. --- 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