Commit 58e84d88 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

py2/py3: use exception.args[] instead of exception[].

parent 9d264965
......@@ -391,14 +391,14 @@ class DB(TM):
try:
self.db.query(query)
except OperationalError as m:
if m[0] in query_syntax_error:
raise OperationalError(m[0], '%s: %s' % (m[1], query))
if m[0] in lock_error:
raise ConflictError('%s: %s: %s' % (m[0], m[1], query))
if m[0] in query_timeout_error:
raise TimeoutReachedError('%s: %s: %s' % (m[0], m[1], query))
if m.args[0] in query_syntax_error:
raise OperationalError(m.args[0], '%s: %s' % (m.args[1], query))
if m.args[0] in lock_error:
raise ConflictError('%s: %s: %s' % (m.args[0], m.args[1], query))
if m.args[0] in query_timeout_error:
raise TimeoutReachedError('%s: %s: %s' % (m.args[0], m.args[1], query))
if (allow_reconnect or not self._use_TM) and \
m[0] in hosed_connection:
m.args[0] in hosed_connection:
self._forceReconnection()
self.db.query(query)
else:
......@@ -415,8 +415,8 @@ class DB(TM):
try:
return self.db.store_result()
except OperationalError as m:
if m[0] in query_timeout_error:
raise TimeoutReachedError('%s: %s: %s' % (m[0], m[1], query))
if m.args[0] in query_timeout_error:
raise TimeoutReachedError('%s: %s: %s' % (m.args[0], m.args[1], query))
else:
raise
......@@ -519,7 +519,7 @@ class DB(TM):
except OperationalError as m:
LOG('ZMySQLDA', ERROR, "exception during _abort",
error=True)
if m[0] not in hosed_connection:
if m.args[0] not in hosed_connection:
raise
def getMaxAllowedPacket(self):
......
......@@ -137,7 +137,7 @@ class TestDeferredConnection(ERP5TypeTestCase):
try:
self.commit()
except OperationalError as m:
if m[0] not in hosed_connection:
if m.args[0] not in hosed_connection:
raise
else:
self.fail()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment