Fixed PostgreSQL version matching after PG 10

Backport to psycopg 2.6 of ticket #489, ticket #632
This commit is contained in:
Daniele Varrazzo 2017-12-01 16:08:03 +00:00
parent b179645ff7
commit 4ae2a36610
2 changed files with 9 additions and 2 deletions

2
NEWS
View File

@ -7,6 +7,8 @@ What's new in psycopg 2.6.3
- Throw an exception trying to pass ``NULL`` chars as parameters
(:ticket:`#420`).
- Make `~psycopg2.extras.Range` objects picklable (:ticket:`#462`).
- Fixed version parsing and building of PostgreSQL 10.
Fix backport for :tickets:`#489, #632`.
What's new in psycopg 2.6.2

View File

@ -415,13 +415,18 @@ class psycopg_build_ext(build_ext):
pgversion = "7.4.0"
verre = re.compile(
r"(\d+)\.(\d+)(?:(?:\.(\d+))|(devel|(alpha|beta|rc)\d+))")
r"(\d+)(?:\.(\d+))?(?:(?:\.(\d+))|(devel|(?:alpha|beta|rc)\d+))?")
m = verre.match(pgversion)
if m:
pgmajor, pgminor, pgpatch = m.group(1, 2, 3)
# Postgres >= 10 doesn't have pgminor anymore.
pgmajor = int(pgmajor)
if pgmajor >= 10:
pgminor, pgpatch = None, pgminor
if pgminor is None or not pgminor.isdigit():
pgminor = 0
if pgpatch is None or not pgpatch.isdigit():
pgpatch = 0
pgmajor = int(pgmajor)
pgminor = int(pgminor)
pgpatch = int(pgpatch)
else: