From 49d8b65f758f54ea2d8b289e603038e168ba0767 Mon Sep 17 00:00:00 2001 From: alisha17 Date: Wed, 4 Oct 2017 00:30:41 +1100 Subject: [PATCH] Ticket 101 - BaseException.message has been deprecated in Python3 Bug Description: Error is caused when some exception is raised in dsidm file becuase BaseException.message has been deprecated in Python3 Fix Description: Using str(Exception) fixes the bug for dsidm as well as all other files using BaseException.message https://pagure.io/lib389/issue/101 Author: Alisha Aneja Review by: William Brown --- cli/dscreate | 2 +- cli/dsctl | 2 +- cli/dsidm | 2 +- lib389/cli_base/__init__.py | 2 +- lib389/tests/krb5_create_test.py | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/dscreate b/cli/dscreate index 1b1ef7a..4743003 100755 --- a/cli/dscreate +++ b/cli/dscreate @@ -70,7 +70,7 @@ By setting this value you acknowledge and take responsibility for the fact this result = args.func(inst, log, args) except Exception as e: log.debug(e, exc_info=True) - log.error("Error: %s" % e.message) + log.error("Error: %s" % str(e)) if result is True: log.info('FINISH: Command succeeded') diff --git a/cli/dsctl b/cli/dsctl index fed1a96..8aa4f4b 100755 --- a/cli/dsctl +++ b/cli/dsctl @@ -85,7 +85,7 @@ if __name__ == '__main__': result = args.func(inst, log, args) except Exception as e: log.debug(e, exc_info=True) - log.error("Error: %s" % e.message) + log.error("Error: %s" % str(e)) disconnect_instance(inst) if result is True: diff --git a/cli/dsidm b/cli/dsidm index 996b71e..1cfc415 100755 --- a/cli/dsidm +++ b/cli/dsidm @@ -107,7 +107,7 @@ if __name__ == '__main__': args.func(inst, dsrc_inst['basedn'], log, args) except Exception as e: log.debug(e, exc_info=True) - log.error("Error: %s" % e.message) + log.error("Error: %s" % str(e)) disconnect_instance(inst) diff --git a/lib389/cli_base/__init__.py b/lib389/cli_base/__init__.py index 3c34366..21bf3cc 100644 --- a/lib389/cli_base/__init__.py +++ b/lib389/cli_base/__init__.py @@ -157,7 +157,7 @@ class LogCapture(logging.Handler): """ result = False for rec in self.outputs: - if query in rec.message: + if query in str(rec): result = True return result diff --git a/lib389/tests/krb5_create_test.py b/lib389/tests/krb5_create_test.py index ec858e2..182d51f 100644 --- a/lib389/tests/krb5_create_test.py +++ b/lib389/tests/krb5_create_test.py @@ -124,7 +124,7 @@ def test_gssapi(topology, add_user): conn0.sasl_interactive_bind_s('', sasl) except Exception as e: print("Exception (expected): %s" % type(e).__name__) - print('Desc ' + e.message['desc']) + print('Desc ' + str(e['desc'])) assert isinstance(e, ldap.INVALID_CREDENTIALS) # undo @@ -136,7 +136,7 @@ def test_gssapi(topology, add_user): conn0.sasl_interactive_bind_s('', sasl) except Exception as e: print("Exception (expected): %s" % type(e).__name__) - print('Desc ' + e.message['desc']) + print('Desc ' + str(e['desc'])) assert isinstance(e, ldap.INVALID_CREDENTIALS) print("SUCCESS") -- 2.13.5