Opened 8 years ago
Closed 8 years ago
#12622 closed defect (fixed)
trac.tests.env.SystemInfoTestCase failure with PostgreSQL on Windows
Reported by: | Christian Boos | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.3.1 |
Component: | database backend | Version: | |
Severity: | minor | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Load |
||
API Changes: | |||
Internal Changes: |
Description
Psycopg2 : 2.6.1 (dt dec pq3 ext lo64) ... PostgreSQL version : psql (PostgreSQL) 9.1.1
FAIL: test_database_backend_version (trac.tests.env.SystemInfoTestCase) Database backend is returned in system_info. ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\Trac\repos\trunk\trac\tests\env.py", line 311, in test_database_backend_version r'^server: \(not-connected\), ' AssertionError: Regexp didn't match: '^server: \\(not-connected\\), client: \\d+(\\.\\d+)+$' not found in 'server: (not-connected), client: (unknown)'
1.2-stable is not affected as the test exists only in trunk.
Attachments (0)
Change History (8)
comment:2 by , 8 years ago
Got a similar one on Linux for MySQL (MariaDB actually):
FAIL: test_database_backend_version (trac.tests.env.SystemInfoTestCase) Database backend is returned in system_info. ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/cboos/trac/trunk/trac/tests/env.py", line 300, in test_database_backend_version r'^server: \(not-connected\), ' AssertionError: Regexp didn't match: '^server: \\(not-connected\\), client: "\\d+(\\.\\d+)+", thread-safe: 1$' not found in 'server: (not-connected), client: "10.0.21-MariaDB", thread-safe: 1' ----------------------------------------------------------------------
follow-up: 4 comment:3 by , 8 years ago
Replying to Christian Boos:
The code trunk/trac/db/postgres_backend.py@15152:287#L281 falls back to
"(unknown)"
because it tries to CDLL load a 32-bit PostgreSQLlibpq.dll
from a 64-bit Python.
Are you using win-psycopg? It seems the win-psycopg is built using static libraries of PostgreSQL libpq 9.5.3. I reconsider we shouldn't try to load libpq.dll
if it is unable to detect that is static linking or dynamic linking.
comment:4 by , 8 years ago
Replying to Jun Omae:
Replying to Christian Boos:
The code trunk/trac/db/postgres_backend.py@15152:287#L281 falls back to
"(unknown)"
because it tries to CDLL load a 32-bit PostgreSQLlibpq.dll
from a 64-bit Python.Are you using win-psycopg?
Yes, I think so, as that's the official port of psycopg2 for Windows.
The lib/site-packages/psycopg2/_psycopg.pyd
library indeed doesn't depend on libpq.dll
.
comment:5 by , 8 years ago
Proposed changes in [f68e43418/jomae.git]. If name of shared library is found in contents of psycopyg2._psycopg.__file__
, try to load.
Linux:
Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from trac.test import EnvironmentStub >>> env = EnvironmentStub() >>> for _ in env.get_systeminfo(): _ ... ('Babel', '2.3.4') ('Genshi', '0.6 (with speedups)') ('PostgreSQL', 'server: 9.1.20, client: 9.3.14') ('psycopg2', '2.6.2') >>> from trac.db.postgres_backend import _libpq_pathname >>> _libpq_pathname 'libpq.so.5'
Mac OS X:
Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from trac.test import EnvironmentStub >>> env = EnvironmentStub() >>> for _ in env.get_systeminfo(): _ ... ('Genshi', '0.6 (without speedups)') ('PostgreSQL', 'server: 9.1.20, client: 9.6.1') ('psycopg2', '2.6.2') >>> from trac.db.postgres_backend import _libpq_pathname >>> _libpq_pathname '/usr/local/opt/postgresql/lib/libpq.5.dylib'
Windows: untested
comment:6 by , 8 years ago
Windows:
Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from trac.test import EnvironmentStub >>> env = EnvironmentStub() >>> for _ in env.get_systeminfo(): _ ... ('Babel', '2.1.1') ('Genshi', '0.7 (with speedups)') ('PostgreSQL', 'server: 9.1.1, client: (unknown)') ('psycopg2', '2.6.1')
And the unit-tests pass on both problematic platforms. Thanks for the fix!
comment:7 by , 8 years ago
Owner: | changed from | to
---|
comment:8 by , 8 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Thanks for the testing! Committed in [15257].
The code trunk/trac/db/postgres_backend.py@15152:287#L281 falls back to
"(unknown)"
because it tries to CDLL load a 32-bit PostgreSQLlibpq.dll
from a 64-bit Python.A more robust approach might be to get the File Version attribute of the .dll (à la SO:580924/python-windows-file-version-attribute).
In the meantime, the following should do:
trac/tests/env.py
\d+(\.\d+)+$')\d+(\.\d+)+$')