From 991f0988ee11f517632a3d1f8b896097f2f6f80c Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 15 Jun 2017 10:11:48 +0100 Subject: [PATCH] Use an import style reported not broken on Python 3.6 Couldn't reproduce the issue but it has been documented in #550. --- NEWS | 2 ++ lib/__init__.py | 2 +- lib/pool.py | 2 +- lib/psycopg1.py | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 0a5de096..a914a7ed 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,8 @@ What's new in psycopg 2.7.2 (:ticket:`#545`). - Fixed `~psycopg2.extras.ReplicationCursor.consume_stream()` *keepalive_interval* argument (:ticket:`#547`). +- Maybe fixed random import error on Python 3.6 in multiprocess + environment (:ticket:`#550`). - Fixed random `!SystemError` upon receiving abort signal (:ticket:`#551`). - Parse intervals returned as microseconds from Redshift (:ticket:`#558`). - Added `~psycopg2.extras.Json` `!prepare()` method to consider connection diff --git a/lib/__init__.py b/lib/__init__.py index 492b924d..f4d4fc79 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -65,7 +65,7 @@ from psycopg2 import tz # noqa # Register default adapters. -import psycopg2.extensions as _ext +from psycopg2 import extensions as _ext _ext.register_adapter(tuple, _ext.SQL_IN) _ext.register_adapter(type(None), _ext.NoneAdapter) diff --git a/lib/pool.py b/lib/pool.py index e57875c8..a91c9cc0 100644 --- a/lib/pool.py +++ b/lib/pool.py @@ -25,7 +25,7 @@ This module implements thread-safe (and not) connection pools. # License for more details. import psycopg2 -import psycopg2.extensions as _ext +from psycopg2 import extensions as _ext class PoolError(psycopg2.Error): diff --git a/lib/psycopg1.py b/lib/psycopg1.py index 3808aaaf..0ee79422 100644 --- a/lib/psycopg1.py +++ b/lib/psycopg1.py @@ -28,12 +28,12 @@ old code while porting to psycopg 2. Import it as follows:: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. -import psycopg2._psycopg as _2psycopg # noqa +from psycopg2 import _psycopg as _2psycopg # noqa from psycopg2.extensions import cursor as _2cursor from psycopg2.extensions import connection as _2connection from psycopg2 import * # noqa -import psycopg2.extensions as _ext +from psycopg2 import extensions as _ext _2connect = connect