From b3b74a4592ea706bceadea6086aea91c353c8127 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Tue, 31 Mar 2026 22:00:12 -0400 Subject: [PATCH 1/3] maugclib: use asyncio.timeout for Python 3.13 This was new in 3.11 so realistically everyone should have it. --- maugclib/channel.py | 3 +-- maugclib/http_utils.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/maugclib/channel.py b/maugclib/channel.py index 1361512..3f325c6 100644 --- a/maugclib/channel.py +++ b/maugclib/channel.py @@ -27,7 +27,6 @@ import time import aiohttp -import async_timeout from mautrix.util.opt_prometheus import Counter @@ -445,7 +444,7 @@ async def _longpoll_request(self) -> None: await self._send_initial_ping() while True: - async with async_timeout.timeout(PUSH_TIMEOUT): + async with asyncio.timeout(PUSH_TIMEOUT): chunk = await res.content.read(MAX_READ_BYTES) if not chunk: break diff --git a/maugclib/http_utils.py b/maugclib/http_utils.py index f8494d6..6b3e337 100644 --- a/maugclib/http_utils.py +++ b/maugclib/http_utils.py @@ -10,7 +10,6 @@ from yarl import URL import aiohttp -import async_timeout from . import exceptions @@ -143,7 +142,7 @@ async def fetch( allow_redirects=allow_redirects, data=data, ) as res: - async with async_timeout.timeout(REQUEST_TIMEOUT): + async with asyncio.timeout(REQUEST_TIMEOUT): body = await res.read() log_body = body if isinstance(url, str) and "/u/0/mole/world" in url: From 2590bb3344e860aa29a73098b64300c5ac29d05a Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Tue, 31 Mar 2026 22:00:12 -0400 Subject: [PATCH 2/3] maugclib: replace use of removed cgi module --- maugclib/client.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/maugclib/client.py b/maugclib/client.py index e3aea80..c617668 100644 --- a/maugclib/client.py +++ b/maugclib/client.py @@ -2,12 +2,12 @@ from __future__ import annotations -from typing import Iterator +from typing import Dict, Iterator +from email.message import EmailMessage from urllib.parse import urlencode import asyncio import base64 import binascii -import cgi import datetime import json import logging @@ -34,6 +34,13 @@ wiz_pattern = re.compile(r">window.WIZ_global_data = ({.+?});") +def parse_header(header: str) -> Dict[str, str]: + """Replacement for the old cgi.parse_header()""" + msg = EmailMessage() + msg["Content-Disposition"] = header + return msg["Content-Disposition"].params + + class Client: """Instant messaging client for Google Chat. @@ -224,7 +231,7 @@ async def download_attachment( resp.raise_for_status() try: - _, params = cgi.parse_header(resp.headers["Content-Disposition"]) + params = parse_header(resp.headers["Content-Disposition"]) filename = params.get("filename") or url.path.split("/")[-1] except KeyError: filename = url.path.split("/")[-1] From 8e76c0696ec3092a0ba03b30cbbdcb97eaf6fe21 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Tue, 31 Mar 2026 22:00:12 -0400 Subject: [PATCH 3/3] mautrix_googlechat: fix for enum auto() change on Python 3.13 At least, that's what I think happened here. This fixes things so it works again. --- .../formatter/from_matrix/gc_message.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mautrix_googlechat/formatter/from_matrix/gc_message.py b/mautrix_googlechat/formatter/from_matrix/gc_message.py index f831a65..81dfb75 100644 --- a/mautrix_googlechat/formatter/from_matrix/gc_message.py +++ b/mautrix_googlechat/formatter/from_matrix/gc_message.py @@ -46,22 +46,22 @@ class GCUserMentionType(Enum): class GCEntityType(Enum): """EntityType is a Matrix formatting entity type.""" - BOLD = GCFormatType.BOLD - ITALIC = GCFormatType.ITALIC - STRIKETHROUGH = GCFormatType.STRIKE - UNDERLINE = GCFormatType.UNDERLINE + BOLD = (GCFormatType.BOLD).value + ITALIC = (GCFormatType.ITALIC).value + STRIKETHROUGH = (GCFormatType.STRIKE).value + UNDERLINE = (GCFormatType.UNDERLINE).value URL = auto() EMAIL = auto() - USER_MENTION = GCUserMentionType.MENTION - MENTION_ALL = GCUserMentionType.MENTION_ALL - PREFORMATTED = GCFormatType.MONOSPACE_BLOCK - INLINE_CODE = GCFormatType.MONOSPACE - COLOR = GCFormatType.FONT_COLOR + USER_MENTION = (GCUserMentionType.MENTION).value + MENTION_ALL = (GCUserMentionType.MENTION_ALL).value + PREFORMATTED = (GCFormatType.MONOSPACE_BLOCK).value + INLINE_CODE = (GCFormatType.MONOSPACE).value + COLOR = (GCFormatType.FONT_COLOR).value # Google Chat specific types, not present in mautrix-python's EntityType - LIST = GCFormatType.BULLETED_LIST - LIST_ITEM = GCFormatType.BULLETED_LIST_ITEM - HIDDEN = GCFormatType.HIDDEN + LIST = (GCFormatType.BULLETED_LIST).value + LIST_ITEM = (GCFormatType.BULLETED_LIST_ITEM).value + HIDDEN = (GCFormatType.HIDDEN).value class GCEntity(SemiAbstractEntity):