From 661df681c8039fa5293ffaeb562ee2f033b51d27 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Mon, 25 Nov 2024 11:24:11 -0800 Subject: [PATCH] fixup 38 references --- .../templates/jobs/extended-tests-jobs.yml | 7 ++-- .../templates/jobs/standard-tests-jobs.yml | 8 ++--- certbot-compatibility-test/Dockerfile | 2 +- .../_internal/tests/compat/filesystem_test.py | 4 --- certbot/certbot/_internal/tests/hook_test.py | 2 -- certbot/certbot/compat/filesystem.py | 36 +++++-------------- tools/pinning/current/pyproject.toml | 2 +- tools/pinning/oldest/pyproject.toml | 2 +- tools/venv.py | 2 +- tox.ini | 2 +- 10 files changed, 20 insertions(+), 47 deletions(-) diff --git a/.azure-pipelines/templates/jobs/extended-tests-jobs.yml b/.azure-pipelines/templates/jobs/extended-tests-jobs.yml index c2779a076..4a804a362 100644 --- a/.azure-pipelines/templates/jobs/extended-tests-jobs.yml +++ b/.azure-pipelines/templates/jobs/extended-tests-jobs.yml @@ -20,14 +20,11 @@ jobs: linux-isolated: TOXENV: 'isolated-acme,isolated-certbot,isolated-apache,isolated-cloudflare,isolated-digitalocean,isolated-dnsimple,isolated-dnsmadeeasy,isolated-gehirn,isolated-google,isolated-linode,isolated-luadns,isolated-nsone,isolated-ovh,isolated-rfc2136,isolated-route53,isolated-sakuracloud,isolated-nginx' linux-integration-certbot-oldest: - PYTHON_VERSION: 3.8 + PYTHON_VERSION: 3.9 TOXENV: integration-certbot-oldest linux-integration-nginx-oldest: - PYTHON_VERSION: 3.8 + PYTHON_VERSION: 3.9 TOXENV: integration-nginx-oldest - linux-py38-integration: - PYTHON_VERSION: 3.8 - TOXENV: integration linux-py39-integration: PYTHON_VERSION: 3.9 TOXENV: integration diff --git a/.azure-pipelines/templates/jobs/standard-tests-jobs.yml b/.azure-pipelines/templates/jobs/standard-tests-jobs.yml index e1474b152..5d9932241 100644 --- a/.azure-pipelines/templates/jobs/standard-tests-jobs.yml +++ b/.azure-pipelines/templates/jobs/standard-tests-jobs.yml @@ -12,13 +12,13 @@ jobs: PIP_USE_PEP517: "true" linux-oldest: IMAGE_NAME: ubuntu-22.04 - PYTHON_VERSION: 3.8 + PYTHON_VERSION: 3.9 TOXENV: oldest - linux-py38: + linux-py39: # linux unit tests with the oldest python we support IMAGE_NAME: ubuntu-22.04 - PYTHON_VERSION: 3.8 - TOXENV: py38 + PYTHON_VERSION: 3.9 + TOXENV: py39 linux-cover: # linux unit+cover tests with the newest python we support IMAGE_NAME: ubuntu-22.04 diff --git a/certbot-compatibility-test/Dockerfile b/certbot-compatibility-test/Dockerfile index 091ab5f85..34a530979 100644 --- a/certbot-compatibility-test/Dockerfile +++ b/certbot-compatibility-test/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/python:3.8-buster +FROM docker.io/python:3.11-buster LABEL maintainer="Brad Warren " # This does not include the dependencies needed to build cryptography. See diff --git a/certbot/certbot/_internal/tests/compat/filesystem_test.py b/certbot/certbot/_internal/tests/compat/filesystem_test.py index 303fbe92b..8004282d4 100644 --- a/certbot/certbot/_internal/tests/compat/filesystem_test.py +++ b/certbot/certbot/_internal/tests/compat/filesystem_test.py @@ -631,10 +631,6 @@ class ReadlinkTest(unittest.TestCase): @unittest.skipIf(POSIX_MODE, reason='Tests specific to Windows') @mock.patch("certbot.compat.filesystem.os.readlink") def test_normal_path_windows(self, mock_readlink): - # Python <3.8 - mock_readlink.return_value = "C:\\short\\path" - assert filesystem.readlink("dummy") == "C:\\short\\path" - # Python >=3.8 (os.readlink always returns the extended form) mock_readlink.return_value = "\\\\?\\C:\\short\\path" assert filesystem.readlink("dummy") == "C:\\short\\path" diff --git a/certbot/certbot/_internal/tests/hook_test.py b/certbot/certbot/_internal/tests/hook_test.py index 7581a9d44..798f2ac83 100644 --- a/certbot/certbot/_internal/tests/hook_test.py +++ b/certbot/certbot/_internal/tests/hook_test.py @@ -218,7 +218,6 @@ class PostHookTest(HookTest): assert not self._call_with_mock_execute(self.config, []).called assert not self._get_eventually() - @unittest.skipIf(pyver_lt(3, 8), "Python 3.8+ required for this test.") def test_renew_env(self): self.config.verb = "certonly" args = self._call_with_mock_execute(self.config, ["success.org"]).call_args @@ -308,7 +307,6 @@ class RunSavedPostHooksTest(HookTest): mock_execute = self._call_with_mock_execute_and_eventually([], []) mock_execute.assert_called_once_with("post-hook", self.eventually[0], env=mock.ANY) - @unittest.skipIf(pyver_lt(3, 8), "Python 3.8+ required for this test.") def test_env(self): self.eventually = ["foo"] mock_execute = self._call_with_mock_execute_and_eventually(["success.org"], ["failed.org"]) diff --git a/certbot/certbot/compat/filesystem.py b/certbot/certbot/compat/filesystem.py index 13fc44098..9db4e0162 100644 --- a/certbot/certbot/compat/filesystem.py +++ b/certbot/certbot/compat/filesystem.py @@ -5,11 +5,9 @@ from contextlib import contextmanager import errno import os # pylint: disable=os-module-forbidden import stat -import sys from typing import Any from typing import Dict from typing import Generator -from typing import List from typing import Optional try: @@ -370,27 +368,14 @@ def realpath(file_path: str) -> str: """ original_path = file_path - # Since Python 3.8, os.path.realpath also resolves symlinks on Windows. - if POSIX_MODE or sys.version_info >= (3, 8): - path = os.path.realpath(file_path) - if os.path.islink(path): - # If path returned by realpath is still a link, it means that it failed to - # resolve the symlink because of a loop. - # See realpath code: https://github.com/python/cpython/blob/master/Lib/posixpath.py - raise RuntimeError('Error, link {0} is a loop!'.format(original_path)) - return path - - inspected_paths: List[str] = [] - while os.path.islink(file_path): - link_path = file_path - file_path = os.readlink(file_path) - if not os.path.isabs(file_path): - file_path = os.path.join(os.path.dirname(link_path), file_path) - if file_path in inspected_paths: - raise RuntimeError('Error, link {0} is a loop!'.format(original_path)) - inspected_paths.append(file_path) - - return os.path.abspath(file_path) + # os.path.realpath also resolves symlinks + path = os.path.realpath(file_path) + if os.path.islink(path): + # If path returned by realpath is still a link, it means that it failed to + # resolve the symlink because of a loop. + # See realpath code: https://github.com/python/cpython/blob/master/Lib/posixpath.py + raise RuntimeError('Error, link {0} is a loop!'.format(original_path)) + return path def readlink(link_path: str) -> str: @@ -404,12 +389,9 @@ def readlink(link_path: str) -> str: """ path = os.readlink(link_path) - if POSIX_MODE or not path.startswith('\\\\?\\'): + if POSIX_MODE: return path - # At this point, we know we are on Windows and that the path returned uses - # the extended form which is done for all paths in Python 3.8+ - # Max length of a normal path is 260 characters on Windows, including the non printable # termination character "". The termination character is not included in Python # strings, giving a max length of 259 characters, + 4 characters for the extended form diff --git a/tools/pinning/current/pyproject.toml b/tools/pinning/current/pyproject.toml index d711e3ffc..ae7df57a9 100644 --- a/tools/pinning/current/pyproject.toml +++ b/tools/pinning/current/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Certbot Project"] license = "Apache License 2.0" [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" # workaround for: https://github.com/python-poetry/poetry-plugin-export/issues/183 urllib3 = ">=1.25.4,<1.27" diff --git a/tools/pinning/oldest/pyproject.toml b/tools/pinning/oldest/pyproject.toml index 1a4d7d71f..ed9ac4619 100644 --- a/tools/pinning/oldest/pyproject.toml +++ b/tools/pinning/oldest/pyproject.toml @@ -10,7 +10,7 @@ license = "Apache License 2.0" [tool.poetry.dependencies] # The Python version here should be kept in sync with the one used in our # oldest tests in tox.ini. -python = "<3.9 >= 3.8" +python = "<3.10 >= 3.9" # Local dependencies # Any local packages that have dependencies on other local packages must be diff --git a/tools/venv.py b/tools/venv.py index 8a3650678..4044258ef 100755 --- a/tools/venv.py +++ b/tools/venv.py @@ -117,7 +117,7 @@ def _check_version(version_str): version = (int(search.group(1)), int(search.group(2))) - if version >= (3, 8): + if version >= (3, 9): return True print('Incompatible python version for Certbot found: {0}'.format(version_str)) diff --git a/tox.ini b/tox.ini index 7fa72525a..bd5462fdb 100644 --- a/tox.ini +++ b/tox.ini @@ -63,7 +63,7 @@ commands = {[testenv:py]commands} # # This version should be kept in sync with the one declared in # tools/pinning/oldest/pyproject.toml. -basepython = python3.8 +basepython = python3.9 setenv = CERTBOT_OLDEST=1 commands = {[testenv:py]commands}