From 35c0d79390ab97c6aabbc7e67eeb202ab1f9f2c6 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Wed, 22 Aug 2018 11:57:51 +0300 Subject: [PATCH] Ensure the correct dbm module is used for all envs --- certbot-apache/certbot_apache/apache_util.py | 4 ++-- certbot-apache/certbot_apache/configurator.py | 6 ++++++ certbot-apache/certbot_apache/tests/ocsp_prefetch_test.py | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/certbot-apache/certbot_apache/apache_util.py b/certbot-apache/certbot_apache/apache_util.py index 4a15ee641..98fe4ef3e 100644 --- a/certbot-apache/certbot_apache/apache_util.py +++ b/certbot-apache/certbot_apache/apache_util.py @@ -138,8 +138,8 @@ def certid_sha1_hex(cert_path): """ sha1_hex = binascii.hexlify(certid_sha1(cert_path)) if isinstance(sha1_hex, six.binary_type): - return sha1_hex.decode('utf-8') - return sha1_hex + return sha1_hex.decode('utf-8') # pragma: no cover + return sha1_hex # pragma: no cover def certid_sha1(cert_path): diff --git a/certbot-apache/certbot_apache/configurator.py b/certbot-apache/certbot_apache/configurator.py index 665254429..8f677377a 100644 --- a/certbot-apache/certbot_apache/configurator.py +++ b/certbot-apache/certbot_apache/configurator.py @@ -39,6 +39,12 @@ from certbot_apache import tls_sni_01 from collections import defaultdict +try: + import dbm.ndbm as dbm # pragma: no cover +except ImportError: # pragma: no cover + # dbm.ndbm only available on Python3 + import dbm # pragma: no cover + logger = logging.getLogger(__name__) diff --git a/certbot-apache/certbot_apache/tests/ocsp_prefetch_test.py b/certbot-apache/certbot_apache/tests/ocsp_prefetch_test.py index 09899d53f..630c04440 100644 --- a/certbot-apache/certbot_apache/tests/ocsp_prefetch_test.py +++ b/certbot-apache/certbot_apache/tests/ocsp_prefetch_test.py @@ -1,5 +1,4 @@ """Test for certbot_apache.configurator OCSP Prefetching functionality""" -import dbm import os import unittest import mock @@ -8,6 +7,12 @@ import six # pylint: disable=unused-import from certbot_apache.tests import util +try: + import dbm.ndbm as dbm # pragma: no cover +except ImportError: # pragma: no cover + # dbm.ndbm only available on Python3 + import dbm # pragma: no cover + class OCSPPrefetchTest(util.ApacheTest): """Tests for OCSP Prefetch feature"""