diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 969fb0c03f..086596068d 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -361,8 +361,8 @@ class FormatStylePlaceholderCursor(Database.Cursor): return Database.Cursor.execute(self, query, self._param_generator(params)) except DatabaseError, e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. - if e.message.code == 1400 and type(e) != IntegrityError: - e = IntegrityError(e.message) + if e.args[0].code == 1400 and not isinstance(e, IntegrityError): + e = IntegrityError(e.args[0]) raise e def executemany(self, query, params=None): @@ -384,8 +384,8 @@ class FormatStylePlaceholderCursor(Database.Cursor): return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted]) except DatabaseError, e: # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400. - if e.message.code == 1400 and type(e) != IntegrityError: - e = IntegrityError(e.message) + if e.args[0].code == 1400 and not isinstance(e, IntegrityError): + e = IntegrityError(e.args[0]) raise e def fetchone(self):