From 4b91f7fbbc70cf9f824c0c41d8d0aaa23a378860 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Sat, 8 Apr 2017 00:58:19 +0800 Subject: [PATCH] Replace e.message with str(e) for Python 3 compatibility (#4416) --- certbot/display/ops.py | 7 +------ certbot/main.py | 4 ++-- certbot/renewal.py | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/certbot/display/ops.py b/certbot/display/ops.py index 85343fdc3..4bbf9e5b8 100644 --- a/certbot/display/ops.py +++ b/certbot/display/ops.py @@ -192,12 +192,7 @@ def _choose_names_manually(prompt_prefix=""): try: domain_list[i] = util.enforce_domain_sanity(domain) except errors.ConfigurationError as e: - try: # Python 2 - # pylint: disable=no-member - err_msg = e.message.encode('utf-8') - except AttributeError: - err_msg = str(e) - invalid_domains[domain] = err_msg + invalid_domains[domain] = str(e) if len(invalid_domains): retry_message = ( diff --git a/certbot/main.py b/certbot/main.py index 64e7d07a4..97b1bcd8a 100644 --- a/certbot/main.py +++ b/certbot/main.py @@ -571,7 +571,7 @@ def revoke(config, unused_plugins): # TODO: coop with renewal config try: acme.revoke(jose.ComparableX509(cert), config.reason) except acme_errors.ClientError as e: - return e.message + return str(e) display_ops.success_revocation(config.cert_path[0]) @@ -583,7 +583,7 @@ def run(config, plugins): # pylint: disable=too-many-branches,too-many-locals try: installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run") except errors.PluginSelectionError as e: - return e.message + return str(e) # TODO: Handle errors from _init_le_client? le_client = _init_le_client(config, authenticator, installer) diff --git a/certbot/renewal.py b/certbot/renewal.py index 6eb171763..2dd804671 100644 --- a/certbot/renewal.py +++ b/certbot/renewal.py @@ -79,7 +79,7 @@ def _reconstitute(config, full_path): except (ValueError, errors.Error) as error: logger.warning( "An error occurred while parsing %s. The error was %s. " - "Skipping the file.", full_path, error.message) + "Skipping the file.", full_path, str(error)) logger.debug("Traceback was:\n%s", traceback.format_exc()) return None