]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Make sure the conn.autocommit attribute is set to a bool
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 25 Jul 2021 19:24:02 +0000 (21:24 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 25 Jul 2021 19:24:02 +0000 (21:24 +0200)
psycopg/psycopg/connection.py

index f8e6fba26a95ffd61b9e04d4db2c5b254667cfc3..ee1d280d5bd73a44a21e150cd869ce2bdb72916f 100644 (file)
@@ -187,7 +187,7 @@ class BaseConnection(Generic[Row]):
         # Base implementation, not thread safe.
         # Subclasses must call it holding a lock
         self._check_intrans("autocommit")
-        self._autocommit = value
+        self._autocommit = bool(value)
 
     @property
     def isolation_level(self) -> Optional[IsolationLevel]:
@@ -428,7 +428,7 @@ class BaseConnection(Generic[Row]):
         if not row_factory:
             row_factory = tuple_row
         conn = cls(pgconn, row_factory)
-        conn._autocommit = autocommit
+        conn._autocommit = bool(autocommit)
         return conn
 
     def _exec_command(self, command: Query) -> PQGen["PGresult"]: