Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[py3] Exception aren't iterable in Python 3.

  • Loading branch information...
commit 7fa51a24a8ca47f41f5d711e81b8a71b08542a36 1 parent d796c94
@aaugustin aaugustin authored
View
16 django/db/backends/mysql/base.py
@@ -118,29 +118,29 @@ def execute(self, query, args=None):
try:
return self.cursor.execute(query, args)
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
except Database.OperationalError as e:
# Map some error codes to IntegrityError, since they seem to be
# misclassified and Django would prefer the more logical place.
if e[0] in self.codes_for_integrityerror:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
except Database.DatabaseError as e:
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def executemany(self, query, args):
try:
return self.cursor.executemany(query, args)
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
except Database.OperationalError as e:
# Map some error codes to IntegrityError, since they seem to be
# misclassified and Django would prefer the more logical place.
if e[0] in self.codes_for_integrityerror:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
except Database.DatabaseError as e:
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def __getattr__(self, attr):
if attr in self.__dict__:
View
18 django/db/backends/oracle/base.py
@@ -550,7 +550,7 @@ def _commit(self):
except Database.IntegrityError as e:
# In case cx_Oracle implements (now or in a future version)
# raising this specific exception
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
except Database.DatabaseError as e:
# cx_Oracle 5.0.4 raises a cx_Oracle.DatabaseError exception
# with the following attributes and values:
@@ -562,8 +562,8 @@ def _commit(self):
x = e.args[0]
if hasattr(x, 'code') and hasattr(x, 'message') \
and x.code == 2091 and 'ORA-02291' in x.message:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
class OracleParam(object):
@@ -689,12 +689,12 @@ def execute(self, query, params=None):
try:
return self.cursor.execute(query, self._param_generator(params))
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
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):
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def executemany(self, query, params=None):
# cx_Oracle doesn't support iterators, convert them to lists
@@ -718,12 +718,12 @@ def executemany(self, query, params=None):
return self.cursor.executemany(query,
[self._param_generator(p) for p in formatted])
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
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):
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def fetchone(self):
row = self.cursor.fetchone()
View
10 django/db/backends/postgresql_psycopg2/base.py
@@ -52,17 +52,17 @@ def execute(self, query, args=None):
try:
return self.cursor.execute(query, args)
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
except Database.DatabaseError as e:
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def executemany(self, query, args):
try:
return self.cursor.executemany(query, args)
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
except Database.DatabaseError as e:
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def __getattr__(self, attr):
if attr in self.__dict__:
@@ -237,4 +237,4 @@ def _commit(self):
try:
return self.connection.commit()
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
View
8 django/db/backends/sqlite3/base.py
@@ -349,18 +349,18 @@ def execute(self, query, params=()):
try:
return Database.Cursor.execute(self, query, params)
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
except Database.DatabaseError as e:
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def executemany(self, query, param_list):
query = self.convert_query(query)
try:
return Database.Cursor.executemany(self, query, param_list)
except Database.IntegrityError as e:
- six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
except Database.DatabaseError as e:
- six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2])
+ six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
def convert_query(self, query):
return FORMAT_QMARK_REGEX.sub('?', query).replace('%%','%')
Please sign in to comment.
Something went wrong with that request. Please try again.