diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e871e265c..199ad7f82 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,10 +43,12 @@ jobs: matrix: include: - os: ubuntu-latest - py: "3.12" + py: "3.13-dev" - os: windows-latest - py: "3.12" + py: "3.13-dev" - os: macos-latest + py: "3.13-dev" + - os: ubuntu-latest py: "3.12" - os: ubuntu-latest py: "3.11" diff --git a/CHANGELOG.md b/CHANGELOG.md index c30cb988c..39d1eae6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ ([#7073](https://github.com/mitmproxy/mitmproxy/pull/7073), @mhils) - Fix a bug where fragmented QUIC client hellos were not handled properly. ([#7067](https://github.com/mitmproxy/mitmproxy/pull/7067), @errorxyz) +- mitmproxy now officially supports Python 3.13. + ([#6934](https://github.com/mitmproxy/mitmproxy/pull/6934), @mhils) ## 02 August 2024: mitmproxy 10.4.2 diff --git a/mitmproxy/net/encoding.py b/mitmproxy/net/encoding.py index 95fd23bf4..ca4a71ace 100644 --- a/mitmproxy/net/encoding.py +++ b/mitmproxy/net/encoding.py @@ -147,16 +147,15 @@ def identity(content): def decode_gzip(content: bytes) -> bytes: if not content: return b"" - gfile = gzip.GzipFile(fileobj=BytesIO(content)) - return gfile.read() + with gzip.GzipFile(fileobj=BytesIO(content)) as f: + return f.read() def encode_gzip(content: bytes) -> bytes: s = BytesIO() # set mtime to 0 so that gzip encoding is deterministic. - gf = gzip.GzipFile(fileobj=s, mode="wb", mtime=0) - gf.write(content) - gf.close() + with gzip.GzipFile(fileobj=s, mode="wb", mtime=0) as f: + f.write(content) return s.getvalue() diff --git a/pyproject.toml b/pyproject.toml index c76b40873..dd4ecda51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Security", "Topic :: Internet :: WWW/HTTP", @@ -65,8 +66,8 @@ dev = [ "click>=7.0,<=8.1.7", "hypothesis>=6.104.2,<=6.108.5", "pdoc>=14.5.1,<=14.6.0", - "pyinstaller==6.9.0", - "pyinstaller-hooks-contrib==2024.7", + "pyinstaller==6.10.0", + "pyinstaller-hooks-contrib==2024.8", "pytest-asyncio>=0.23.6,<=0.23.8", "pytest-cov>=5.0.0,<=5.0.0", "pytest-timeout>=2.3.1,<=2.3.1",