Convert all databases modules to python3 and 2.4 syntax (#3688)

This commit is contained in:
Michael Scherer 2016-05-18 16:07:21 +02:00 committed by Matt Clay
parent f7b29ba8fd
commit 09066f1518
6 changed files with 54 additions and 28 deletions

View file

@ -573,7 +573,8 @@ def main():
module.fail_json(msg='Python module "psycopg2" must be installed.')
try:
conn = Connection(p)
except psycopg2.Error, e:
except psycopg2.Error:
e = get_exception()
module.fail_json(msg='Could not connect to database: %s' % e)
try:
@ -613,11 +614,13 @@ def main():
schema_qualifier=p.schema
)
except Error, e:
except Error:
e = get_exception()
conn.rollback()
module.fail_json(msg=e.message)
except psycopg2.Error, e:
except psycopg2.Error:
e = get_exception()
conn.rollback()
# psycopg2 errors come in connection encoding, reencode
msg = e.message.decode(conn.encoding).encode(sys.getdefaultencoding(),