]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Fixed import of optimized Transformer
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 23 Apr 2020 04:28:32 +0000 (16:28 +1200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 23 Apr 2020 04:28:32 +0000 (16:28 +1200)
Import it if the C module is used, not just if it's available.

psycopg3/adapt.py

index bc316402eb04ea091986c6bee3e6844324c2c990..33cd0af792fdc8b32c5d678ef3f4e1bad3ce6252 100644 (file)
@@ -409,7 +409,6 @@ def _connection_from_context(
         raise TypeError(f"can't get a connection from {type(context)}")
 
 
-try:
+# Override it with fast object if available
+if pq.__impl__ == "c":
     from ._psycopg3 import Transformer  # noqa
-except ImportError:
-    pass