From: Daniele Varrazzo Date: Fri, 7 Aug 2020 00:52:23 +0000 (+0100) Subject: Added guard to avoid importing psycog3_c without psycopg3 X-Git-Tag: 3.0.dev0~458^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e6db11247d75bc00e754906cfe8e90ce54777f0;p=thirdparty%2Fpsycopg.git Added guard to avoid importing psycog3_c without psycopg3 Doing so result in mysterious import error. --- diff --git a/psycopg3_c/psycopg3_c/__init__.py b/psycopg3_c/psycopg3_c/__init__.py index 8ab3af86f..9093563a7 100644 --- a/psycopg3_c/psycopg3_c/__init__.py +++ b/psycopg3_c/psycopg3_c/__init__.py @@ -4,4 +4,13 @@ psycopg3 -- PostgreSQL database adapter for Python -- C optimization package # Copyright (C) 2020 The Psycopg Team +import sys + +# This package shouldn't be imported before psycopg3 itself, or weird things +# will happen +if "psycopg3" not in sys.modules: + raise ImportError( + "the psycopg3 package should be imported before psycopg3_c" + ) + from .version import __version__ # noqa