[PATCH] D68798: [LNT] Python 3 support: fix printing of exceptions
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 08:42:33 PDT 2019
thopre created this revision.
thopre added reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls.
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.
https://reviews.llvm.org/D68798
Files:
lnt/server/db/migrations/upgrade_15_to_16.py
lnt/server/db/migrations/upgrade_16_to_17.py
lnt/tests/test_suite.py
lnt/util/ImportData.py
Index: lnt/util/ImportData.py
===================================================================
--- lnt/util/ImportData.py
+++ lnt/util/ImportData.py
@@ -112,7 +112,7 @@
raise
except Exception as e:
import traceback
- result['error'] = "import failure: %s" % e.message
+ result['error'] = "import failure: %s" % e
result['message'] = traceback.format_exc()
if isinstance(e, lnt.server.db.testsuitedb.MachineInfoChanged):
result['message'] += \
Index: lnt/tests/test_suite.py
===================================================================
--- lnt/tests/test_suite.py
+++ lnt/tests/test_suite.py
@@ -634,7 +634,7 @@
return json.loads(open(output_json_path.name).read())
except ValueError as e:
fatal("Running test-suite did not create valid json report "
- "in {}: {}".format(output_json_path.name, e.message))
+ "in {}: {}".format(output_json_path.name, e))
def _is_pass_code(self, code):
return code in ('PASS', 'XPASS', 'XFAIL')
Index: lnt/server/db/migrations/upgrade_16_to_17.py
===================================================================
--- lnt/server/db/migrations/upgrade_16_to_17.py
+++ lnt/server/db/migrations/upgrade_16_to_17.py
@@ -15,7 +15,7 @@
try:
fast_fc_lookup.create(engine)
except (sqlalchemy.exc.OperationalError, sqlalchemy.exc.ProgrammingError) as e:
- logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e.message))
+ logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e))
def upgrade(engine):
Index: lnt/server/db/migrations/upgrade_15_to_16.py
===================================================================
--- lnt/server/db/migrations/upgrade_15_to_16.py
+++ lnt/server/db/migrations/upgrade_15_to_16.py
@@ -15,7 +15,7 @@
try:
fast_fc_lookup.create(engine)
except (sqlalchemy.exc.OperationalError, sqlalchemy.exc.ProgrammingError) as e:
- logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e.message))
+ logger.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e))
def upgrade(engine):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68798.224363.patch
Type: text/x-patch
Size: 2286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/622f83f0/attachment.bin>
More information about the llvm-commits
mailing list