The code: - https://github.com/python/cpython/blob/719e5c3f7111bcda5eee72fe648786c427c4d4c2/Lib/csv.py#L473 The docs: - https://docs.python.org/3/library/csv.html#csv.Sniffer.has_header - https://github.com/python/cpython/blob/379161dd51c2cf67568e007fbb5fa225e73c9e10/Doc/library/csv.rst#L297 > Twenty rows after the first row are sampled This is an off-by-one: the code iterates 21 rows, not 20. I err on correcting the docs, instead of the code, given that users may rely on the current behavior. <!-- gh-linked-prs --> ### Linked PRs * gh-137953 * gh-141434 * gh-141435 <!-- /gh-linked-prs -->
The code:
cpython/Lib/csv.py
Line 473 in 719e5c3
The docs:
cpython/Doc/library/csv.rst
Line 297 in 379161d
This is an off-by-one: the code iterates 21 rows, not 20.
I err on correcting the docs, instead of the code, given that users may rely on the current behavior.
Linked PRs
csv.Sniffer().has_header()docs to describe the actual off-by-onish behavior #137953csv.Sniffer().has_header()docs to describe the actual off-by-onish behavior (GH-137953) #141434csv.Sniffer().has_header()docs to describe the actual off-by-onish behavior (GH-137953) #141435