diff --git a/changelog.d/9270.misc b/changelog.d/9270.misc new file mode 100644 index 000000000000..314f5d4484f6 --- /dev/null +++ b/changelog.d/9270.misc @@ -0,0 +1 @@ +Restore PyPy compatibility by using psycopg2cffi consistently. diff --git a/synapse/storage/engines/__init__.py b/synapse/storage/engines/__init__.py index 035f9ea6e98b..f0c6ad356480 100644 --- a/synapse/storage/engines/__init__.py +++ b/synapse/storage/engines/__init__.py @@ -30,9 +30,11 @@ def create_engine(database_config) -> BaseDatabaseEngine: if name == "psycopg2": # pypy requires psycopg2cffi rather than psycopg2 if platform.python_implementation() == "PyPy": - import psycopg2cffi as psycopg2 # type: ignore - else: - import psycopg2 # type: ignore + from psycopg2cffi import compat # type: ignore + + compat.register() + + import psycopg2 # type: ignore return PostgresEngine(psycopg2, database_config)