Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 7c8402d

Browse files
authored
Suppress CryptographyDeprecationWarning (#9698)
This warning is somewhat confusing to users, so let's suppress it
1 parent b5efcb5 commit 7c8402d

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

changelog.d/9698.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Suppress "CryptographyDeprecationWarning: int_from_bytes is deprecated".

synapse/app/_base.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
import socket
2222
import sys
2323
import traceback
24+
import warnings
2425
from typing import Awaitable, Callable, Iterable
2526

27+
from cryptography.utils import CryptographyDeprecationWarning
2628
from typing_extensions import NoReturn
2729

2830
from twisted.internet import defer, error, reactor
@@ -195,6 +197,25 @@ def listen_metrics(bind_addresses, port):
195197
start_http_server(port, addr=host, registry=RegistryProxy)
196198

197199

200+
def listen_manhole(bind_addresses: Iterable[str], port: int, manhole_globals: dict):
201+
# twisted.conch.manhole 21.1.0 uses "int_from_bytes", which produces a confusing
202+
# warning. It's fixed by https://github.com/twisted/twisted/pull/1522), so
203+
# suppress the warning for now.
204+
warnings.filterwarnings(
205+
action="ignore",
206+
category=CryptographyDeprecationWarning,
207+
message="int_from_bytes is deprecated",
208+
)
209+
210+
from synapse.util.manhole import manhole
211+
212+
listen_tcp(
213+
bind_addresses,
214+
port,
215+
manhole(username="matrix", password="rabbithole", globals=manhole_globals),
216+
)
217+
218+
198219
def listen_tcp(bind_addresses, port, factory, reactor=reactor, backlog=50):
199220
"""
200221
Create a TCP socket for a port and several addresses

synapse/app/generic_worker.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147
from synapse.types import ReadReceipt
148148
from synapse.util.async_helpers import Linearizer
149149
from synapse.util.httpresourcetree import create_resource_tree
150-
from synapse.util.manhole import manhole
151150
from synapse.util.versionstring import get_version_string
152151

153152
logger = logging.getLogger("synapse.app.generic_worker")
@@ -640,12 +639,8 @@ def start_listening(self, listeners: Iterable[ListenerConfig]):
640639
if listener.type == "http":
641640
self._listen_http(listener)
642641
elif listener.type == "manhole":
643-
_base.listen_tcp(
644-
listener.bind_addresses,
645-
listener.port,
646-
manhole(
647-
username="matrix", password="rabbithole", globals={"hs": self}
648-
),
642+
_base.listen_manhole(
643+
listener.bind_addresses, listener.port, manhole_globals={"hs": self}
649644
)
650645
elif listener.type == "metrics":
651646
if not self.get_config().enable_metrics:

synapse/app/homeserver.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
from synapse.storage.engines import IncorrectDatabaseSetup
6868
from synapse.storage.prepare_database import UpgradeDatabaseException
6969
from synapse.util.httpresourcetree import create_resource_tree
70-
from synapse.util.manhole import manhole
7170
from synapse.util.module_loader import load_module
7271
from synapse.util.versionstring import get_version_string
7372

@@ -288,12 +287,8 @@ def start_listening(self, listeners: Iterable[ListenerConfig]):
288287
if listener.type == "http":
289288
self._listening_services.extend(self._listener_http(config, listener))
290289
elif listener.type == "manhole":
291-
listen_tcp(
292-
listener.bind_addresses,
293-
listener.port,
294-
manhole(
295-
username="matrix", password="rabbithole", globals={"hs": self}
296-
),
290+
_base.listen_manhole(
291+
listener.bind_addresses, listener.port, manhole_globals={"hs": self}
297292
)
298293
elif listener.type == "replication":
299294
services = listen_tcp(

0 commit comments

Comments
 (0)