@@ -302,18 +302,21 @@ def convert_range(lo: int, hi: int, error: Optional[Exception]) -> None:
302302 convert_range (0 , n , batch_error )
303303 failed = sum (isinstance (r , _FailedRow ) for r in rows )
304304 # One summary line, no traceback: the error itself still reaches the caller
305- # when the failing row is fetched. The full traceback is only logged at DEBUG.
305+ # when the failing row is fetched. Only the exception type is logged here,
306+ # since conversion error messages often quote the offending result value;
307+ # the message and full traceback are only logged at DEBUG.
306308 # ``log_level`` lets the caller log this at WARNING only once per result set.
307309 logger .log (
308310 log_level ,
309311 "fetchone(): failed to convert %d of %d row(s) in a batch; each failing "
310- "row raises when fetched (%s: %s )" ,
312+ "row raises when fetched (%s)" ,
311313 failed ,
312314 n ,
313315 type (batch_error ).__name__ ,
314- batch_error ,
315316 )
316- logger .debug ("fetchone(): batch conversion error" , exc_info = batch_error )
317+ logger .debug (
318+ "fetchone(): batch conversion error: %s" , batch_error , exc_info = batch_error
319+ )
317320 return rows
318321
319322 def _cap_to_current_chunk (self , size : int ) -> int :
@@ -369,7 +372,11 @@ def _fetchone_buffered(
369372 If conversion yields a different number of rows than the raw chunk held,
370373 ``InternalError`` is raised and that whole chunk is dropped (the queue and
371374 ``rownumber`` have already moved past it). The result set should be
372- considered unusable after that error.
375+ considered unusable after that error. The same holds when conversion
376+ raises one of ``_NON_DATA_CONVERSION_ERRORS`` (e.g. ``MemoryError``,
377+ ``RecursionError``): the error is re-raised and the whole refill chunk
378+ (up to ``_FETCHONE_BUFFER_MAX_ROWS`` rows, still counted in ``rownumber``)
379+ is lost, so callers should not keep fetching from this result set.
373380 """
374381 if self ._row_buffer_count () == 0 :
375382 cap = max (min (self .arraysize , _FETCHONE_BUFFER_MAX_ROWS ), 1 )
@@ -383,6 +390,9 @@ def _fetchone_buffered(
383390 except _NON_DATA_CONVERSION_ERRORS :
384391 # Resource / interpreter failures say nothing about individual
385392 # rows; retrying smaller slices would only repeat (or worsen) them.
393+ # The queue has already moved past ``raw`` and it is not buffered,
394+ # so the whole refill chunk is lost: as with the drift error below,
395+ # the result set is unusable after this.
386396 raise
387397 except Exception as batch_error :
388398 # The queue has already moved past this batch, so it can't be
0 commit comments