Bug report
Bug description:
Documented behaviour: The Python csv documentation, under DictReader.line_num, says: “The number of lines read from the source iterator. This is not the same as the number of records returned, as records can span multiple lines.”
Expected: After exhaustion, reader.line_num == 3.
Actual: All three source lines are consumed, but reader.line_num == 2.
import csv
lines = ['name\n', '\n', '\n']
if list(csv.reader(lines)) != [['name'], [], []]:
print('REFUTATION REJECTED: input is not a header followed by valid blank CSV lines')
else:
consumed = []
reader = csv.DictReader(consumed.append(line) or line for line in lines)
list(reader)
actual, expected = reader.line_num, len(consumed)
if actual != expected:
print('REFUTATION CONFIRMED:', lines, 'actual:', actual, 'expected:', expected)
else:
print('REFUTATION REJECTED: line_num equals the number of source lines consumed')
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library csv:
REFUTATION CONFIRMED: ['name\n', '\n', '\n'] actual: 2 expected: 3
This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/csv-20261003-022404-c3
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: The Python csv documentation, under DictReader.line_num, says: “The number of lines read from the source iterator. This is not the same as the number of records returned, as records can span multiple lines.”
Expected: After exhaustion, reader.line_num == 3.
Actual: All three source lines are consumed, but reader.line_num == 2.
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library
csv:This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/csv-20261003-022404-c3
CPython versions tested on:
3.14
Operating systems tested on:
Windows