Commit beff2b0
authored
csv: port CPython reader state machine (#8381)
* csv: port CPython reader state machine
Replace the csv-core reader and per-item quote scanner with one Rust
implementation of CPython's nine-state reader parser. Keep parser state
across iterator items and distinguish virtual item boundaries from true
iterator exhaustion.
Centralize field completion so quote provenance, empty-field None conversion,
float conversion, strict parsing, field limits, blank rows, and escaped or
quoted newlines share one path. Apply the existing reentrant-iterator
generation check to every iterator item consumed by a record.
Also accept empty ASCII line terminators like CPython, report a missing
csv-core writer sentinel as _csv.Error instead of panicking, and name the
FSM entry point process_parser_input.
Remove the expected-failure markers from the eleven reader tests that now
pass.
Assisted-by: Codex:gpt-5.6-sol
* csv: test CRLF boundaries with custom lineterminator1 parent 4d890b3 commit beff2b0
4 files changed
Lines changed: 311 additions & 375 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
375 | 374 | | |
376 | 375 | | |
377 | 376 | | |
| |||
382 | 381 | | |
383 | 382 | | |
384 | 383 | | |
385 | | - | |
386 | 384 | | |
387 | 385 | | |
388 | 386 | | |
| |||
397 | 395 | | |
398 | 396 | | |
399 | 397 | | |
400 | | - | |
401 | 398 | | |
402 | 399 | | |
403 | 400 | | |
| |||
407 | 404 | | |
408 | 405 | | |
409 | 406 | | |
410 | | - | |
411 | 407 | | |
412 | 408 | | |
413 | 409 | | |
| |||
420 | 416 | | |
421 | 417 | | |
422 | 418 | | |
423 | | - | |
424 | 419 | | |
425 | 420 | | |
426 | 421 | | |
| |||
433 | 428 | | |
434 | 429 | | |
435 | 430 | | |
436 | | - | |
437 | 431 | | |
438 | 432 | | |
439 | 433 | | |
| |||
484 | 478 | | |
485 | 479 | | |
486 | 480 | | |
487 | | - | |
488 | 481 | | |
489 | 482 | | |
490 | 483 | | |
| |||
524 | 517 | | |
525 | 518 | | |
526 | 519 | | |
527 | | - | |
528 | 520 | | |
529 | 521 | | |
530 | 522 | | |
| |||
543 | 535 | | |
544 | 536 | | |
545 | 537 | | |
546 | | - | |
547 | 538 | | |
548 | 539 | | |
549 | 540 | | |
| |||
807 | 798 | | |
808 | 799 | | |
809 | 800 | | |
810 | | - | |
811 | 801 | | |
812 | 802 | | |
813 | 803 | | |
| |||
1078 | 1068 | | |
1079 | 1069 | | |
1080 | 1070 | | |
1081 | | - | |
1082 | 1071 | | |
1083 | 1072 | | |
1084 | 1073 | | |
| |||
0 commit comments