From f5e870dcc031cf3dd023ab3351a0a4d2464ea085 Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Fri, 13 Nov 2020 12:05:20 -0700 Subject: Combine included libraries into one parameter build_ext only grabs one '-l' parameter, not multiple, which is weird as one time I thought it did. --- scripts/appveyor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/appveyor.py b/scripts/appveyor.py index 4b6cc85..24aca67 100755 --- a/scripts/appveyor.py +++ b/scripts/appveyor.py @@ -326,7 +326,7 @@ def build_psycopg(): add_pg_config_path() run_python( ["setup.py", "build_ext", "--have-ssl"] - + ["-l", "libpgcommon", "-l", "libpgport"] + + ["-l", "libpgcommon libpgport"] + ["-L", opt.ssl_build_dir / 'lib'] + ['-I', opt.ssl_build_dir / 'include'] ) -- cgit v1.2.1 From 12b1432fe10c7f9c478cda99b00c674b3a74058b Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Fri, 13 Nov 2020 12:17:48 -0700 Subject: Build more OpenSSL binaries and add to path More recent verions of the PostgreSQL source code requires some OpenSSL binaries to be on the PATH. --- scripts/appveyor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/appveyor.py b/scripts/appveyor.py index 24aca67..ea6263d 100755 --- a/scripts/appveyor.py +++ b/scripts/appveyor.py @@ -53,6 +53,7 @@ def setup_build_env(): str(opt.py_dir / 'Scripts'), r'C:\Strawberry\Perl\bin', r'C:\Program Files\Git\mingw64\bin', + str(opt.ssl_build_dir / 'bin'), os.environ['PATH'], ] setenv('PATH', os.pathsep.join(path)) @@ -212,7 +213,7 @@ def build_openssl(): + ['no-shared', 'no-zlib', f'--prefix={top}', f'--openssldir={top}'] ) - run_command("nmake build_libs install_dev".split()) + run_command("nmake build_libs install_sw".split()) assert (top / 'lib' / 'libssl.lib').exists() -- cgit v1.2.1 From e3f8cf0702428514974733ccc62b855df078fd6b Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Fri, 13 Nov 2020 12:22:38 -0700 Subject: Remove old patch for Postgres 9.6 and OpenSSL 1.1 --- scripts/appveyor.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/scripts/appveyor.py b/scripts/appveyor.py index ea6263d..37bcd5c 100755 --- a/scripts/appveyor.py +++ b/scripts/appveyor.py @@ -250,20 +250,6 @@ def build_libpq(): pgbuild = opt.build_dir / f"postgres-REL_{ver}" os.chdir(pgbuild) - # Patch for OpenSSL 1.1 configuration. See: - # https://www.postgresql-archive.org/Compile-psql-9-6-with-SSL-Version-1-1-0-td6054118.html - assert Path("src/include/pg_config.h.win32").exists() - with open("src/include/pg_config.h.win32", 'a') as f: - print( - """ -#define HAVE_ASN1_STRING_GET0_DATA 1 -#define HAVE_BIO_GET_DATA 1 -#define HAVE_BIO_METH_NEW 1 -#define HAVE_OPENSSL_INIT_SSL 1 -""", - file=f, - ) - # Setup build config file (config.pl) os.chdir("src/tools/msvc") with open("config.pl", 'w') as f: -- cgit v1.2.1 From f1dfbd59af9b31ef2c3ffc51be0bbc32eec005ec Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Fri, 13 Nov 2020 12:24:12 -0700 Subject: Build against PostgreSQL 13.0 and removed Py27/34 PostgreSQL 12 and 13 do not support older Microsoft Visual Studio compilers and therefore we can not build against Python 2.7 and Python 3.4 --- .appveyor.yml | 6 +----- scripts/appveyor.cache_rebuild | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index b79302b..8972119 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,13 +21,9 @@ environment: - {APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015, PY_VER: "36", PY_ARCH: "64"} - {APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015, PY_VER: "35", PY_ARCH: "32"} - {APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015, PY_VER: "35", PY_ARCH: "64"} - - {APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015, PY_VER: "34", PY_ARCH: "32"} - - {APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015, PY_VER: "34", PY_ARCH: "64"} - - {APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015, PY_VER: "27", PY_ARCH: "32"} - - {APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015, PY_VER: "27", PY_ARCH: "64"} OPENSSL_VERSION: "1_1_1h" - POSTGRES_VERSION: "11_4" + POSTGRES_VERSION: "13_0" PSYCOPG2_TESTDB: psycopg2_test PSYCOPG2_TESTDB_USER: postgres diff --git a/scripts/appveyor.cache_rebuild b/scripts/appveyor.cache_rebuild index 432d68e..419eb94 100644 --- a/scripts/appveyor.cache_rebuild +++ b/scripts/appveyor.cache_rebuild @@ -12,7 +12,7 @@ OpenSSL Version: 1.1.1h PostgreSQL - Version: 11.4 + Version: 13.0 NOTE: to zap the cache manually you can also use: -- cgit v1.2.1 From cdca0a20e04853b3ea3e70524feef4c43992073e Mon Sep 17 00:00:00 2001 From: Justas Sadzevicius Date: Mon, 7 Sep 2020 09:44:44 +0300 Subject: Classify connection exceptions as operational errors to better conform with PEP 249 --- NEWS | 9 +++++++++ psycopg/error_type.c | 2 ++ tests/test_errors.py | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/NEWS b/NEWS index 3bd03f3..bd2c5a2 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,15 @@ Current release --------------- +What's new in psycopg 2.9.0 +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Reclassified SQLSTATE connection exceptions (08XXX) as + `~psycopg2.errors.OperationalError`, conforming better to + PEP 249. This error is a subclass of previously used + `~psycopg2.errors.DatabaseError`. + + What's new in psycopg 2.8.6 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/psycopg/error_type.c b/psycopg/error_type.c index 37b4d4a..60b2c48 100644 --- a/psycopg/error_type.c +++ b/psycopg/error_type.c @@ -65,6 +65,8 @@ base_exception_from_sqlstate(const char *sqlstate) switch (sqlstate[0]) { case '0': switch (sqlstate[1]) { + case '8': /* Class 08 - Connection Exception */ + return OperationalError; case 'A': /* Class 0A - Feature Not Supported */ return NotSupportedError; } diff --git a/tests/test_errors.py b/tests/test_errors.py index bd3e7fd..ec2950c 100755 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -62,6 +62,13 @@ class ErrorsTests(ConnectingTestCase): with self.assertRaises(KeyError): errors.lookup('XXXXX') + def test_connection_exceptions_backwards_compatibility(self): + err = errors.lookup('08000') + # connection exceptions are classified as operational errors + self.assert_(issubclass(err, errors.OperationalError)) + # previously these errors were classified only as DatabaseError + self.assert_(issubclass(err, errors.DatabaseError)) + def test_has_base_exceptions(self): excs = [] for n in dir(psycopg2): -- cgit v1.2.1