Skip to content

Commit c57e3b0

Browse files
author
Thomas Preud'homme
committed
[LNT] Python 3 support: fix printing of exceptions
Summary: A number of SQLAlchemy exception are printed by using their message attribute. However PEP-352 deprecates this attribute from Python 2.6 onwards and drop it for Python 3 and later versions. This commit replaces printing the message attribute by printing the exception itself, relying on the __str__ method. This is actually equivalent for exceptions with only a single argument (as required for all exceptions on Python 3) as can be seen by the message property getter in the aforementioned PEP. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls, leandron, PrzemekWirkus Reviewed By: PrzemekWirkus Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D68798
1 parent d935e95 commit c57e3b0

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lnt/server/db/migrations/upgrade_15_to_16.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _mk_index_on(engine, ts_name):
1515
try:
1616
fast_fc_lookup.create(engine)
1717
except (sqlalchemy.exc.OperationalError, sqlalchemy.exc.ProgrammingError) as e:
18-
logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e.message))
18+
logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e))
1919

2020

2121
def upgrade(engine):

lnt/server/db/migrations/upgrade_16_to_17.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _mk_index_on(engine, ts_name):
1515
try:
1616
fast_fc_lookup.create(engine)
1717
except (sqlalchemy.exc.OperationalError, sqlalchemy.exc.ProgrammingError) as e:
18-
logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e.message))
18+
logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e))
1919

2020

2121
def upgrade(engine):

lnt/tests/test_suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def _lit(self, path, test, profile):
637637
return json.loads(open(output_json_path.name).read())
638638
except ValueError as e:
639639
fatal("Running test-suite did not create valid json report "
640-
"in {}: {}".format(output_json_path.name, e.message))
640+
"in {}: {}".format(output_json_path.name, e))
641641

642642
def _is_pass_code(self, code):
643643
return code in ('PASS', 'XPASS', 'XFAIL')

lnt/util/ImportData.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def import_and_report(config, db_name, db, session, file, format, ts_name,
112112
raise
113113
except Exception as e:
114114
import traceback
115-
result['error'] = "import failure: %s" % e.message
115+
result['error'] = "import failure: %s" % e
116116
result['message'] = traceback.format_exc()
117117
if isinstance(e, lnt.server.db.testsuitedb.MachineInfoChanged):
118118
result['message'] += \

0 commit comments

Comments
 (0)