[py3k] except as
authorSamuel Trégouët <samuel.tregouet@logilab.fr>
Fri, 11 Sep 2015 14:28:06 +0200
changeset 10588 fdaa0e4b7eaf
parent 10587 72447be71b48
child 10589 7c23b7de2b8d
[py3k] except as
devtools/__init__.py
devtools/htmlparser.py
ext/rest.py
rqlrewrite.py
server/sqlutils.py
web/cors.py
web/test/data/views.py
--- a/devtools/__init__.py	Fri Sep 11 14:27:34 2015 +0200
+++ b/devtools/__init__.py	Fri Sep 11 14:28:06 2015 +0200
@@ -541,7 +541,7 @@
         try:
             subprocess.check_call(['initdb', '-D', datadir, '-E', 'utf-8', '--locale=C'])
 
-        except OSError, err:
+        except OSError as err:
             if err.errno == errno.ENOENT:
                 raise OSError('"initdb" could not be found. '
                               'You should add the postgresql bin folder to your PATH '
@@ -560,7 +560,7 @@
         subprocess.check_call(['pg_ctl', 'start', '-w', '-D', datadir,
                                '-o', options],
                               env=env)
-    except OSError, err:
+    except OSError as err:
         if err.errno == errno.ENOENT:
             raise OSError('"pg_ctl" could not be found. '
                           'You should add the postgresql bin folder to your PATH '
--- a/devtools/htmlparser.py	Fri Sep 11 14:27:34 2015 +0200
+++ b/devtools/htmlparser.py	Fri Sep 11 14:28:06 2015 +0200
@@ -167,7 +167,7 @@
         inpsrc.setByteStream(StringIO(data))
         try:
             self._parser.parse(inpsrc)
-        except sax.SAXParseException, exc:
+        except sax.SAXParseException as exc:
             new_exc = AssertionError(u'invalid document: %s' % exc)
             new_exc.position = (exc._linenum, exc._colnum)
             raise new_exc
--- a/ext/rest.py	Fri Sep 11 14:27:34 2015 +0200
+++ b/ext/rest.py	Fri Sep 11 14:28:06 2015 +0200
@@ -168,7 +168,7 @@
         rql = params['rql']
         if vid is None:
             vid = params.get('vid')
-    except (ValueError, KeyError), exc:
+    except (ValueError, KeyError) as exc:
         msg = inliner.reporter.error('Could not parse bookmark path %s [%s].'
                                      % (bookmark.path, exc), line=lineno)
         prb = inliner.problematic(rawtext, rawtext, msg)
@@ -182,7 +182,7 @@
             vid = 'noresult'
         view = _cw.vreg['views'].select(vid, _cw, rset=rset)
         content = view.render()
-    except Exception, exc:
+    except Exception as exc:
         content = 'An error occurred while interpreting directive bookmark: %r' % exc
     set_classes(options)
     return [nodes.raw('', content, format='html')], []
--- a/rqlrewrite.py	Fri Sep 11 14:27:34 2015 +0200
+++ b/rqlrewrite.py	Fri Sep 11 14:28:06 2015 +0200
@@ -427,7 +427,7 @@
     def insert_varmap_snippets(self, varmap, rqlexprs, varexistsmap):
         try:
             self.init_from_varmap(varmap, varexistsmap)
-        except VariableFromSubQuery, ex:
+        except VariableFromSubQuery as ex:
             # variable may have been moved to a newly inserted subquery
             # we should insert snippet in that subquery
             subquery = self.select.aliases[ex.variable].query
--- a/server/sqlutils.py	Fri Sep 11 14:27:34 2015 +0200
+++ b/server/sqlutils.py	Fri Sep 11 14:28:06 2015 +0200
@@ -86,7 +86,7 @@
         try:
             # some dbapi modules doesn't accept unicode for sql string
             execute(str(sql))
-        except Exception, err:
+        except Exception as err:
             if cnx:
                 cnx.rollback()
             failed.append(sql)
--- a/web/cors.py	Fri Sep 11 14:27:34 2015 +0200
+++ b/web/cors.py	Fri Sep 11 14:28:06 2015 +0200
@@ -50,7 +50,7 @@
                 process_preflight(req, config)
         else: # Simple CORS or actual request
             process_simple(req, config)
-    except CORSFailed, exc:
+    except CORSFailed as exc:
         info('Cross origin resource sharing failed: %s' % exc)
     except CORSPreflight:
         info('Cross origin resource sharing: valid Preflight request %s')
--- a/web/test/data/views.py	Fri Sep 11 14:27:34 2015 +0200
+++ b/web/test/data/views.py	Fri Sep 11 14:28:06 2015 +0200
@@ -45,7 +45,7 @@
         for key, value in self._cw.form.iteritems():
             result_dict[key] = _recursive_replace_stream_by_content(value)
         return result_dict
-    except Exception, ex:
+    except Exception as ex:
         import traceback as tb
         tb.print_exc(ex)