[Calypso] [PATCH] Use python3 compatibe exception syntax

Guido Günther agx at sigxcpu.org
Sat Apr 8 14:58:23 PDT 2017


---
 calypso/__init__.py |  2 +-
 calypso/acl/pam.py  |  2 +-
 calypso/webdav.py   | 22 +++++++++++-----------
 setup.py            |  2 +-
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/calypso/__init__.py b/calypso/__init__.py
index a2ed176..0ff8698 100644
--- a/calypso/__init__.py
+++ b/calypso/__init__.py
@@ -233,7 +233,7 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
             log.error("Request timed out: %r", e)
             self.close_connection = 1
             return
-        except ssl.SSLError, x:
+        except ssl.SSLError as x:
             #an io error. Discard this connection
             log.error("SSL request error: %r", x.args[0])
             self.close_connection = 1
diff --git a/calypso/acl/pam.py b/calypso/acl/pam.py
index 01e063c..9baa400 100644
--- a/calypso/acl/pam.py
+++ b/calypso/acl/pam.py
@@ -50,7 +50,7 @@ def has_right(owner, user, password):
         auth.authenticate()
         auth.acct_mgmt()
         return True
-    except PAM.error, resp:
+    except PAM.error as resp:
         LOG.debug('PAM error: %s', resp)
     return False
 
diff --git a/calypso/webdav.py b/calypso/webdav.py
index 0bbf5cf..3e2dead 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -175,7 +175,7 @@ class Item(object):
         """
         try:
             return self.object.serialize().decode('utf-8')
-        except vobject.base.ValidateError, e:
+        except vobject.base.ValidateError as e:
             self.log.warn('Validation error %s in %s', e, self.urlpath)
             return self.object.serialize(validate=False).decode('utf-8')
 
@@ -267,7 +267,7 @@ class Collection(object):
         try:
             item = self.read_file(path)
             self.my_items.append(item)
-        except Exception, ex:
+        except Exception as ex:
             self.log.exception("Insert %s failed", path)
             return
 
@@ -275,7 +275,7 @@ class Collection(object):
         try:
             item = Collection(path)
             self.my_items.append(item)
-        except Exception, ex:
+        except Exception as ex:
             self.log.exception("Insert %s failed", path)
             return
 
@@ -421,7 +421,7 @@ class Collection(object):
             # Touch directory so that another running instance will update
             try:
                 os.utime(self.path, None)
-            except Exception, ex:
+            except Exception as ex:
                 self.log.exception("Failed to set directory mtime")
 
     def write_file(self, item):
@@ -445,7 +445,7 @@ class Collection(object):
         if not os.path.exists(os.path.dirname(self.path)):
             try:
                 os.makedirs(os.path.dirname(self.path))
-            except OSError, ose:
+            except OSError as ose:
                 self.log.exception("Failed to make collection directory %s: %s", self.path, ose)
                 raise
 
@@ -454,10 +454,10 @@ class Collection(object):
             path = self.write_file(item)
             self.git_add(path, context=context)
             self.scan_dir(True)
-        except OSError, ex:
+        except OSError as ex:
             self.log.exception("Error writing file")
             raise
-        except Exception, ex:
+        except Exception as ex:
             self.log.exception("Caught Exception")
             self.log.debug("Failed to create %s: %s", self.path,  ex)
             raise
@@ -469,7 +469,7 @@ class Collection(object):
             os.unlink(item.path)
             self.git_rm(item.path, context=context)
             self.scan_dir(True)
-        except Exception, ex:
+        except Exception as ex:
             self.log.exception("Failed to remove %s", item.path)
             raise
 
@@ -482,7 +482,7 @@ class Collection(object):
             self.scan_file(item.path)
             self.git_change(item.path, context=context)
             self.scan_dir(True)
-        except Exception, ex:
+        except Exception as ex:
             self.log.exception("Failed to rewrite %s", item.path)
             raise
 
@@ -511,7 +511,7 @@ class Collection(object):
         self.log.debug('append name %s', name)
         try:
             new_item = Item(text, name, None, self.urlpath)
-        except Exception, e:
+        except Exception as e:
             self.log.exception("Cannot create new item")
             raise
         if new_item.name in (item.name for item in self.my_items):
@@ -584,7 +584,7 @@ class Collection(object):
                     new_item = Item(new_ics.serialize().decode('utf-8'), None, path, self.urlpath)
                     self.import_item(new_item, path)
             return True
-        except Exception, ex:
+        except Exception as ex:
             self.log.exception("Failed to import: %s", path)
             return False
 
diff --git a/setup.py b/setup.py
index 3347920..97ea94e 100755
--- a/setup.py
+++ b/setup.py
@@ -42,7 +42,7 @@ from setuptools import setup
 
 try:
     from calypso import VERSION
-except ImportError, e:
+except ImportError as e:
     print 'Error importing Calypso, probably dependencies are not installed'
     print e
     VERSION = '0.0.1'
-- 
2.11.0


More information about the Calypso mailing list