@@ -5310,24 +5310,28 @@ def _fetch_line(self, timeout: int=-1) -> Optional[str]:
53105310 if self .response .get_tag () != isc_info_end : # pragma: no cover
53115311 raise InterfaceError ("Malformed result buffer (missing isc_info_end item)" )
53125312 return result
5313- def _read_output (self , * , init : str = '' , timeout : int = - 1 ) -> None :
5313+ def _query_output (self , timeout : int ) -> None :
53145314 assert self ._svc is not None
53155315 self .response .clear ()
53165316 self ._svc .query (self ._make_request (timeout ), bytes ([self .mode ]), self .response .raw )
53175317 tag = self .response .get_tag ()
53185318 if tag != self .mode : # pragma: no cover
53195319 raise InterfaceError (f"Service responded with error code: { tag } " )
5320- data = self .response .read_sized_string (encoding = self .encoding , errors = self .encoding_errors )
5321- init += data
5322- if data and self .mode is SrvInfoCode .LINE :
5323- init += '\n '
5324- self .__line_buffer = init .splitlines (keepends = True )
5320+ return self .response .read_sized_string (encoding = self .encoding , errors = self .encoding_errors )
5321+ def _read_output (self , * , init : str = '' , timeout : int = - 1 ) -> None :
5322+ data = self ._query_output (timeout )
53255323 if self .mode is SrvInfoCode .TO_EOF :
53265324 self ._eof = self .response .get_tag () == isc_info_end
5327- else :
5325+ else : # LINE mode
5326+ self ._eof = not data
5327+ while self .response .get_tag () == isc_info_truncated :
5328+ data += self ._query_output (timeout )
53285329 if self .response .get_tag () != isc_info_end : # pragma: no cover
53295330 raise InterfaceError ("Malformed result buffer (missing isc_info_end item)" )
5330- self ._eof = not data
5331+ init += data
5332+ if data and self .mode is SrvInfoCode .LINE :
5333+ init += '\n '
5334+ self .__line_buffer = init .splitlines (keepends = True )
53315335 def _read_all_binary_output (self , * , timeout : int = - 1 ) -> bytes :
53325336 assert self ._svc is not None
53335337 send = self ._make_request (timeout )
@@ -5375,6 +5379,8 @@ def readline(self) -> Optional[str]:
53755379 if self ._eof :
53765380 return line
53775381 self ._read_output (init = line )
5382+ while not self .__line_buffer [0 ].endswith ('\n ' ):
5383+ self ._read_output (init = self .__line_buffer .pop (0 ))
53785384 if self .__line_buffer :
53795385 return self .__line_buffer .pop (0 )
53805386 return None
@@ -5475,7 +5481,7 @@ def connect_server(server: str, *, user: str=None, password: str=None,
54755481 srv_config = driver_config .get_server (server )
54765482 if srv_config is None :
54775483 srv_config = driver_config .server_defaults
5478- host = server
5484+ host = server if server else None
54795485 else :
54805486 host = srv_config .host .value
54815487 if host is None :
0 commit comments