From a3abcc001a1dff41a6ecd90f779cf038e2f32cc9 Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Wed, 3 Mar 2021 22:10:56 +0100 Subject: [PATCH] Removed a Python 2 fallback in certbot.Reverter. (#8694) * Removed a Python 2 fallback in certbot.Reverter. * Removed a Python < 3.6 fallback in certbot-apache._internal.parser. --- certbot-apache/certbot_apache/_internal/parser.py | 5 ----- certbot/certbot/reverter.py | 8 +++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/certbot-apache/certbot_apache/_internal/parser.py b/certbot-apache/certbot_apache/_internal/parser.py index fdef167bc..a1ea02b18 100644 --- a/certbot-apache/certbot_apache/_internal/parser.py +++ b/certbot-apache/certbot_apache/_internal/parser.py @@ -3,8 +3,6 @@ import copy import fnmatch import logging import re -import sys - from acme.magic_typing import Dict from acme.magic_typing import List @@ -737,9 +735,6 @@ class ApacheParser: :rtype: str """ - if sys.version_info < (3, 6): - # This strips off final /Z(?ms) - return fnmatch.translate(clean_fn_match)[:-7] # pragma: no cover # Since Python 3.6, it returns a different pattern like (?s:.*\.load)\Z return fnmatch.translate(clean_fn_match)[4:-3] # pragma: no cover diff --git a/certbot/certbot/reverter.py b/certbot/certbot/reverter.py index 363215dd0..e6777a7da 100644 --- a/certbot/certbot/reverter.py +++ b/certbot/certbot/reverter.py @@ -3,7 +3,6 @@ import csv import glob import logging import shutil -import sys import time import traceback @@ -251,11 +250,10 @@ class Reverter: def _run_undo_commands(self, filepath): """Run all commands in a file.""" - # NOTE: csv module uses native strings. That is, bytes on Python 2 and - # unicode on Python 3 + # NOTE: csv module uses native strings. That is unicode on Python 3 # It is strongly advised to set newline = '' on Python 3 with CSV, # and it fixes problems on Windows. - kwargs = {'newline': ''} if sys.version_info[0] > 2 else {} + kwargs = {'newline': ''} with open(filepath, 'r', **kwargs) as csvfile: # type: ignore csvreader = csv.reader(csvfile) for command in reversed(list(csvreader)): @@ -354,7 +352,7 @@ class Reverter: command_file = None # It is strongly advised to set newline = '' on Python 3 with CSV, # and it fixes problems on Windows. - kwargs = {'newline': ''} if sys.version_info[0] > 2 else {} + kwargs = {'newline': ''} try: if os.path.isfile(commands_fp): command_file = open(commands_fp, "a", **kwargs) # type: ignore