diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-04-28 18:09:37 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-04-29 20:57:15 +0200 |
| commit | 3904b74a3f2f92fefe1d39281ed683c52f2fef03 (patch) | |
| tree | 1ae8f65371ed53df205553f41c9d0f90d1e9fee9 /django/db/backends/oracle/base.py | |
| parent | eefb00f30124f775ca52258ccd8549054fe8230f (diff) | |
| download | django-3904b74a3f2f92fefe1d39281ed683c52f2fef03.tar.gz | |
Fixed #18013 -- Use the new 'as' syntax for exceptions.
Thanks Clueless for the initial patch.
Note that unittest has been purposely left out (external package only used by Python 2.6).
Diffstat (limited to 'django/db/backends/oracle/base.py')
| -rw-r--r-- | django/db/backends/oracle/base.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index fc02ac41b2..9c91baaca7 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -18,7 +18,7 @@ def _setup_environment(environ): if platform.system().upper().startswith('CYGWIN'): try: import ctypes - except ImportError, e: + except ImportError as e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("Error loading ctypes: %s; " "the Oracle backend requires ctypes to " @@ -41,7 +41,7 @@ _setup_environment([ try: import cx_Oracle as Database -except ImportError, e: +except ImportError as e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e) @@ -532,11 +532,11 @@ class DatabaseWrapper(BaseDatabaseWrapper): if self.connection is not None: try: return self.connection.commit() - except Database.IntegrityError, e: + except Database.IntegrityError as e: # In case cx_Oracle implements (now or in a future version) # raising this specific exception raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] - except Database.DatabaseError, e: + except Database.DatabaseError as e: # cx_Oracle 5.0.4 raises a cx_Oracle.DatabaseError exception # with the following attributes and values: # code = 2091 @@ -673,9 +673,9 @@ class FormatStylePlaceholderCursor(object): self._guess_input_sizes([params]) try: return self.cursor.execute(query, self._param_generator(params)) - except Database.IntegrityError, e: + except Database.IntegrityError as e: raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] - except Database.DatabaseError, e: + except Database.DatabaseError as e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError): raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] @@ -702,9 +702,9 @@ class FormatStylePlaceholderCursor(object): try: return self.cursor.executemany(query, [self._param_generator(p) for p in formatted]) - except Database.IntegrityError, e: + except Database.IntegrityError as e: raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] - except Database.DatabaseError, e: + except Database.DatabaseError as e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError): raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] |
