@@ -272,7 +272,8 @@ def _dot_postgresql_path(filename) -> typing.Optional[pathlib.Path]:
272272
273273
274274def _parse_connect_dsn_and_args (* , dsn , host , port , user ,
275- password , passfile , database , ssl , service ,
275+ password , passfile , database , ssl ,
276+ service , servicefile ,
276277 direct_tls , server_settings ,
277278 target_session_attrs , krbsrvname , gsslib ):
278279 # `auth_hosts` is the version of host information for the purposes
@@ -297,7 +298,11 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
297298 if not service and val :
298299 service = val
299300
300- connection_service_file = os .getenv ('PGSERVICEFILE' )
301+ connection_service_file = servicefile
302+
303+ if connection_service_file is None :
304+ connection_service_file = os .getenv ('PGSERVICEFILE' )
305+
301306 if connection_service_file is None :
302307 homedir = compat .get_pg_home_directory ()
303308 if homedir :
@@ -859,7 +864,7 @@ def _parse_connect_arguments(*, dsn, host, port, user, password, passfile,
859864 max_cacheable_statement_size ,
860865 ssl , direct_tls , server_settings ,
861866 target_session_attrs , krbsrvname , gsslib ,
862- service ):
867+ service , servicefile ):
863868 local_vars = locals ()
864869 for var_name in {'max_cacheable_statement_size' ,
865870 'max_cached_statement_lifetime' ,
@@ -889,7 +894,8 @@ def _parse_connect_arguments(*, dsn, host, port, user, password, passfile,
889894 direct_tls = direct_tls , database = database ,
890895 server_settings = server_settings ,
891896 target_session_attrs = target_session_attrs ,
892- krbsrvname = krbsrvname , gsslib = gsslib , service = service )
897+ krbsrvname = krbsrvname , gsslib = gsslib ,
898+ service = service , servicefile = servicefile )
893899
894900 config = _ClientConfiguration (
895901 command_timeout = command_timeout ,
0 commit comments