From fc539e8c0925630f345c74bc2699d74b56e0d799 Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Mon, 10 Dec 2018 05:09:50 +0200 Subject: Fix regex type --- signald/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/signald/main.py b/signald/main.py index 15125d9..047baae 100644 --- a/signald/main.py +++ b/signald/main.py @@ -6,6 +6,9 @@ from typing import Iterator, List # noqa from .types import Attachment, Message +# We'll need to know the compiled RE object later. +RE_TYPE = type(re.compile("")) + def readlines(s: socket.socket) -> Iterator[bytes]: "Read a socket, line by line." @@ -142,7 +145,7 @@ class Signal: """ A decorator that registers a chat handler function with a regex. """ - if not isinstance(regex, re._pattern_type): + if not isinstance(regex, RE_TYPE): regex = re.compile(regex, re.I) def decorator(func): -- cgit v1.2.3-54-g00ecf