Skip to content

Commit

Permalink
Drop Python 3.8 (#8797)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Aug 20, 2024
1 parent e13175f commit 5be5af3
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 30 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,13 @@ jobs:
needs: gen_llhttp
strategy:
matrix:
pyver: [3.8, 3.9, '3.10', '3.11', '3.12']
pyver: [3.9, '3.10', '3.11', '3.12']
no-extensions: ['', 'Y']
os: [ubuntu, macos, windows]
experimental: [false]
exclude:
- os: macos
no-extensions: 'Y'
- os: macos
pyver: 3.8
- os: windows
no-extensions: 'Y'
include:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: >-
pip install -r requirements/lint.in -c requirements/lint.txt
Expand All @@ -33,4 +33,4 @@ jobs:
body: |
Update versions of tools in pre-commit
configs to latest version
labels: dependencies backport-3.7 backport-3.8
labels: dependencies backport-3.10 backport-3.11
1 change: 1 addition & 0 deletions CHANGES/8797.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped support for Python 3.8 -- by :user:`Dreamsorcerer`.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ define run_tests_in_docker
docker run --rm -ti -v `pwd`:/src -w /src "aiohttp-test-$(1)-$(2)" $(TEST_SPEC)
endef

.PHONY: test-3.8-no-extensions test-3.8 test-3.9-no-extensions test
test-3.8-no-extensions:
$(call run_tests_in_docker,3.8,y)
test-3.8:
$(call run_tests_in_docker,3.8,n)
.PHONY: test-3.9-no-extensions test
test-3.9-no-extensions:
$(call run_tests_in_docker,3.9,y)
test-3.9:
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CookieJar(AbstractCookieJar):
except (OSError, ValueError):
# Hit the maximum representable time on Windows
# https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/localtime-localtime32-localtime64
# Throws ValueError on PyPy 3.8 and 3.9, OSError elsewhere
# Throws ValueError on PyPy 3.9, OSError elsewhere
MAX_TIME = calendar.timegm((3000, 12, 31, 23, 59, 59, -1, -1, -1))
except OverflowError:
# #4515: datetime.max may not be representable on 32-bit platforms
Expand Down
6 changes: 2 additions & 4 deletions aiohttp/resolver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import socket
import sys
from typing import Any, List, Tuple, Type, Union

from .abc import AbstractResolver, ResolveResult
Expand All @@ -18,7 +17,6 @@


_NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV
_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)


class ThreadedResolver(AbstractResolver):
Expand Down Expand Up @@ -49,7 +47,7 @@ async def resolve(
# IPv6 is not supported by Python build,
# or IPv6 is not enabled in the host
continue
if address[3] and _SUPPORTS_SCOPE_ID:
if address[3]:
# This is essential for link-local IPv6 addresses.
# LL IPv6 is a VERY rare case. Strictly speaking, we should use
# getnameinfo() unconditionally, but performance makes sense.
Expand Down Expand Up @@ -107,7 +105,7 @@ async def resolve(
address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr
family = node.family
if family == socket.AF_INET6:
if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:
if len(address) > 3 and address[3]:
# This is essential for link-local IPv6 addresses.
# LL IPv6 is a VERY rare case. Strictly speaking, we should use
# getnameinfo() unconditionally, but performance makes sense.
Expand Down
4 changes: 0 additions & 4 deletions aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import os
import pathlib
import sys
from contextlib import suppress
from mimetypes import MimeTypes
from stat import S_ISREG
Expand Down Expand Up @@ -45,9 +44,6 @@

CONTENT_TYPES: Final[MimeTypes] = MimeTypes()

if sys.version_info < (3, 9):
CONTENT_TYPES.encodings_map[".br"] = "br"

# File extension to IANA encodings map that will be checked in the order defined.
ENCODING_EXTENSIONS = MappingProxyType(
{ext: CONTENT_TYPES.encodings_map[ext] for ext in (".br", ".gz")}
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ classifiers =

Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Expand All @@ -42,7 +41,7 @@ classifiers =
Topic :: Internet :: WWW/HTTP

[options]
python_requires = >=3.8
python_requires = >=3.9
packages = aiohttp
# https://setuptools.readthedocs.io/en/latest/setuptools.html#setting-the-zip-safe-flag
zip_safe = False
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from setuptools import Extension, setup

if sys.version_info < (3, 8):
raise RuntimeError("aiohttp 4.x requires Python 3.8+")
if sys.version_info < (3, 9):
raise RuntimeError("aiohttp 4.x requires Python 3.9+")


NO_EXTENSIONS: bool = bool(os.environ.get("AIOHTTP_NO_EXTENSIONS"))
Expand Down
7 changes: 0 additions & 7 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from aiohttp.resolver import (
_NUMERIC_SOCKET_FLAGS,
_SUPPORTS_SCOPE_ID,
AsyncResolver,
DefaultResolver,
ThreadedResolver,
Expand Down Expand Up @@ -138,9 +137,6 @@ async def test_async_resolver_positive_ipv4_lookup(loop: Any) -> None:


@pytest.mark.skipif(not getaddrinfo, reason="aiodns >=3.2.0 required")
@pytest.mark.skipif(
not _SUPPORTS_SCOPE_ID, reason="python version does not support scope id"
)
async def test_async_resolver_positive_link_local_ipv6_lookup(loop: Any) -> None:
with patch("aiodns.DNSResolver") as mock:
mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result(
Expand Down Expand Up @@ -203,9 +199,6 @@ async def test_threaded_resolver_positive_lookup() -> None:
ipaddress.ip_address(real[0]["host"])


@pytest.mark.skipif(
not _SUPPORTS_SCOPE_ID, reason="python version does not support scope id"
)
async def test_threaded_resolver_positive_ipv6_link_local_lookup() -> None:
loop = Mock()
loop.getaddrinfo = fake_ipv6_addrinfo(["fe80::1"])
Expand Down

0 comments on commit 5be5af3

Please sign in to comment.