From d92d61fa25c0aa50297ba198d42e92906fb5315f Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 26 May 2023 21:01:26 +0300 Subject: [PATCH] Fix Python 3.8 compatibility --- mautrix/__init__.py | 2 +- mautrix/appservice/as_handler.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mautrix/__init__.py b/mautrix/__init__.py index ce7df73a..455409e9 100644 --- a/mautrix/__init__.py +++ b/mautrix/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.19.15" +__version__ = "0.19.16" __author__ = "Tulir Asokan " __all__ = [ "api", diff --git a/mautrix/appservice/as_handler.py b/mautrix/appservice/as_handler.py index b49a8583..9d5ad20a 100644 --- a/mautrix/appservice/as_handler.py +++ b/mautrix/appservice/as_handler.py @@ -83,7 +83,9 @@ def _check_token(self, request: web.Request) -> bool: token = request.rel_url.query["access_token"] except KeyError: try: - token = request.headers["Authorization"].removeprefix("Bearer ") + token = request.headers["Authorization"] + if token.startswith("Bearer "): + token = token[len("Bearer "):] except (KeyError, AttributeError): self.log.trace("No access_token nor Authorization header in request") return False