Commit c0bd358
committed
gh-153634: Raise csv.Error, not ValueError, from csv.Sniffer for an inconsistent guessed dialect
csv.Sniffer.sniff could return a dialect whose delimiter equaled its quote character. Using that dialect (directly, or via csv.Sniffer.has_header, which builds a reader from the sniffed dialect) leaked a raw ValueError from the _csv extension instead of the module's own csv.Error. sniff now validates its guessed dialect before returning it and re-raises the _csv ValueError as csv.Error, so both sniff and has_header report the module exception type. The direct csv.reader and csv.writer paths and the Dialect._validate TypeError/ValueError behavior are unchanged.1 parent 832bc0b commit c0bd358
3 files changed
Lines changed: 22 additions & 0 deletions
File tree
- Lib
- test
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
267 | 275 | | |
268 | 276 | | |
269 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1463 | 1463 | | |
1464 | 1464 | | |
1465 | 1465 | | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
1466 | 1476 | | |
1467 | 1477 | | |
1468 | 1478 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments