diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-11-17 21:41:22 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-11-17 21:51:24 +0000 |
commit | e18d27c4750211dd48127d3cb1f637180d12d132 (patch) | |
tree | f624be85f2258ea8ab49d2e8e291a66ead99ac7b | |
parent | 625cc1b402b33799757fb9b8fe421a2ea63e1236 (diff) | |
download | psycopg2-e18d27c4750211dd48127d3cb1f637180d12d132.tar.gz |
Reproducing/documenting odd behaviours of connect()
-rw-r--r-- | lib/__init__.py | 8 |
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( |