From 69f75254062043a79412065d7f47e156a8d9c38f Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 3 Dec 2017 11:21:35 -0800 Subject: [PATCH] Officially deprecate psycopg1 module Per the module's comment, using psycopg1 is considered a temporary hack that should not be relied on long term. Import now reports a warning. The warning instructs users to use the modern module instead. Allows removing the workaround in a future version. The psycopg1 has been available since the very first psycopg2 module. Allowing plenty of time for users to migrate. --- NEWS | 3 ++- lib/psycopg1.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 54094e90..93754eff 100644 --- a/NEWS +++ b/NEWS @@ -7,7 +7,8 @@ What's new in psycopg 2.8 Other changes: - Dropped support for Python 2.6, 3.2, 3.3. - +- Importing psycopg2.psycopg1 is now deprecated. Use psycopg2 instead. The + psycopg1 module will be removed in a future version. What's new in psycopg 2.7.4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/lib/psycopg1.py b/lib/psycopg1.py index 0ee79422..d392cf0f 100644 --- a/lib/psycopg1.py +++ b/lib/psycopg1.py @@ -27,6 +27,7 @@ old code while porting to psycopg 2. Import it as follows:: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. +import warnings from psycopg2 import _psycopg as _2psycopg # noqa from psycopg2.extensions import cursor as _2cursor @@ -36,6 +37,12 @@ from psycopg2 import * # noqa from psycopg2 import extensions as _ext _2connect = connect +warnings.warn( + 'Importing psycopg1 is deprecated. Use psycopg2 module instead. The ' + 'psycopg1 module will be removed in a future version.', + DeprecationWarning, +) + def connect(*args, **kwargs): """connect(dsn, ...) -> new psycopg 1.1.x compatible connection object"""