summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/__init__.py b/lib/__init__.py
index f42d081..0a8ed0f 100644
--- a/lib/__init__.py
+++ b/lib/__init__.py
@@ -149,8 +149,10 @@ def connect(dsn=None,
library: the list of supported parameter depends on the library version.
"""
-
if dsn is None:
+ # Note: reproducing the behaviour of the previous C implementation:
+ # keyword are silently swallowed if a DSN is specified. I would have
+ # raised an exception. File under "histerical raisins".
items = []
if database is not None:
items.append(('dbname', database))
@@ -160,7 +162,9 @@ def connect(dsn=None,
items.append(('password', password))
if host is not None:
items.append(('host', host))
- if port is not None:
+ # Reproducing the previous C implementation behaviour: swallow a
+ # negative port. The libpq would raise an exception for it.
+ if port is not None and int(port) > 0:
items.append(('port', port))
items.extend(