@@ -284,6 +284,8 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
284
284
285
285
if dsn :
286
286
parsed = urllib .parse .urlparse (dsn )
287
+
288
+ query = None
287
289
if parsed .query :
288
290
query = urllib .parse .parse_qs (parsed .query , strict_parsing = True )
289
291
for key , val in query .items ():
@@ -306,7 +308,6 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
306
308
connection_service_file = pathlib .Path (connection_service_file )
307
309
308
310
if connection_service_file is not None and service is not None :
309
- # TODO Open and parse connection service file
310
311
pg_service = configparser .ConfigParser ()
311
312
pg_service .read (connection_service_file )
312
313
if service in pg_service .sections ():
@@ -396,8 +397,6 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
396
397
if gsslib is None :
397
398
gsslib = val
398
399
399
- if dsn :
400
- parsed = urllib .parse .urlparse (dsn )
401
400
402
401
if parsed .scheme not in {'postgresql' , 'postgres' }:
403
402
raise exceptions .ClientConfigurationError (
@@ -433,11 +432,7 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
433
432
if password is None and dsn_password :
434
433
password = urllib .parse .unquote (dsn_password )
435
434
436
- if parsed .query :
437
- query = urllib .parse .parse_qs (parsed .query , strict_parsing = True )
438
- for key , val in query .items ():
439
- if isinstance (val , list ):
440
- query [key ] = val [- 1 ]
435
+ if query :
441
436
442
437
if 'port' in query :
443
438
val = query .pop ('port' )
0 commit comments