1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-26 07:41:33 +03:00

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.
This commit is contained in:
Mads Jensen
2021-03-03 22:10:56 +01:00
committed by GitHub
parent 9643e85b4c
commit a3abcc001a
2 changed files with 3 additions and 10 deletions

View File

@@ -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

View File

@@ -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