Commits

Aymeric Augustin  committed 1a104c9

Use except ... as ... syntax.

  • Participants
  • Parent commits 496e5fe

Comments (0)

Files changed (10)

File south/creator/actions.py

             else:
                 try:
                     result = eval(code, {}, {"datetime": datetime_utils})
-                except (SyntaxError, NameError), e:
+                except (SyntaxError, NameError) as e:
                     print " ! Invalid input: %s" % e
                 else:
                     break

File south/db/firebird.py

             for sql, values in sqls:
                 try:
                     self.execute("ALTER TABLE %s %s;" % (self.quote_name(table_name), sql), values)
-                except DatabaseError, e:
+                except DatabaseError as e:
                     print e
 
 

File south/db/generic.py

 
         try:
             cursor.execute(sql, params)
-        except DatabaseError, e:
+        except DatabaseError as e:
             print >> sys.stderr, 'FATAL ERROR - The following SQL query failed: %s' % sql
             print >> sys.stderr, 'The error was: %s' % e
             raise

File south/db/oracle.py

         for sql_template, params in sql_templates:
             try:
                 self.execute(sql_template % params)
-            except DatabaseError, exc:
+            except DatabaseError as exc:
                 description = str(exc)
                 # Oracle complains if a column is already NULL/NOT NULL
                 if 'ORA-01442' in description or 'ORA-01451' in description:

File south/management/commands/migrate.py

         for app_name in settings.INSTALLED_APPS:
             try:
                 import_module('.management', app_name)
-            except ImportError, exc:
+            except ImportError as exc:
                 msg = exc.args[0]
                 if not msg.startswith('No module named') or 'management' not in msg:
                     raise

File south/management/commands/migrationcheck.py

                     dummy = model._default_manager.exists()
             except (KeyboardInterrupt, SystemExit):
                 raise
-            except Exception, e:
+            except Exception as e:
                 failures += 1
                 if verbosity >= 1:
                     self.stderr.write(err_msg % app_name)

File south/management/commands/syncdb.py

             for app_name in settings.INSTALLED_APPS:
                 try:
                     import_module('.management', app_name)
-                except ImportError, exc:
+                except ImportError as exc:
                     msg = exc.args[0]
                     if not msg.startswith('No module named') or 'management' not in msg:
                         raise

File south/migration/base.py

         except KeyError:
             try:
                 migration = __import__(full_name, {}, {}, ['Migration'])
-            except ImportError, e:
+            except ImportError as e:
                 raise exceptions.UnknownMigration(self, sys.exc_info())
-            except Exception, e:
+            except Exception as e:
                 raise exceptions.BrokenMigration(self, sys.exc_info())
         # Override some imports
         migration._ = lambda x: x  # Fake i18n

File south/orm.py

             # OK, add it.
             try:
                 results[key] = self.eval_in_context(code, app)
-            except (NameError, AttributeError), e:
+            except (NameError, AttributeError) as e:
                 raise ValueError("Cannot successfully create meta field '%s' for model '%s.%s': %s." % (
                     key, app, model, e
                 ))
                 for fname, (code, extra_imports) in model._failed_fields.items():
                     try:
                         field = self.eval_in_context(code, app, extra_imports)
-                    except (NameError, AttributeError, AssertionError, KeyError), e:
+                    except (NameError, AttributeError, AssertionError, KeyError) as e:
                         # It's failed again. Complain.
                         raise ValueError("Cannot successfully create field '%s' for model '%s': %s." % (
                             fname, modelname, e

File south/tests/logic.py

                           migrations, target_name='zero', fake=False)
         try:
             migrate_app(migrations, target_name=None, fake=False)
-        except exceptions.InconsistentMigrationHistory, e:
+        except exceptions.InconsistentMigrationHistory as e:
             self.assertEqual(
                 [
                     (
             )
         try:
             migrate_app(migrations, target_name="zero", fake=False)
-        except exceptions.InconsistentMigrationHistory, e:
+        except exceptions.InconsistentMigrationHistory as e:
             self.assertEqual(
                 [
                     (
         )
         try:
             depends(target, lambda n: graph[n])
-        except exceptions.CircularDependency, e:
+        except exceptions.CircularDependency as e:
             self.assertEqual(trace, e.trace)
 
     def test_depends_cycle(self):