Repository navigation
csv: preserve dialect conversion errors and ordering - #9020
Conversation
Collect raw dialect fields and keyword overrides before converting them in CPython 3.14 order. Preserve truth-conversion exceptions, read classes without instantiating them, and retain defaulting for failed attribute lookup. Use one shared parser for reader, writer, registry, and native dialect construction. Extend the existing CSV snippet with class, instance, direct-construction, lookup, override, conversion-order, and argument-binding regressions. Assisted-by: OpenAI Codex:model identifier unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Make CSV dialect construction collect raw attributes and keyword overrides before converting fields, using Python 3.14's lookup/conversion order.
strict,doublequote, andskipinitialspacetruth conversion for instances, classes, native_csv.Dialect, and dialect registration.quotechar=None.This is a coherent replacement of the existing duplicated dialect-conversion paths. A one-line
strictpropagation change is insufficient: the old parser also replaces exceptions, instantiates class inputs, and converts overridden attributes before applying keyword options. The shared path removes the duplicated conversion code.The strict-conversion issue was identified while auditing #8954. That PR's attribute-lookup propagation was intentionally not copied because CPython 3.14 ignores attribute lookup failures here.
Validation
Base:
bd8fdb7e5ca3e4e9f78f4f34b122a84c9dd2e2d0.Head:
62a324e740cf0f19a219e358304bce24bd0212de.Reference: CPython 3.14.7, Linux x86_64.
extra_tests/snippets/stdlib_csv.pyfails the separately built, immutable current-main executable because astrict.__bool__exception is suppressed.-m test test_csvpasses on baseline and patched RustPython: 134 tests, 6 skips. Existing expected-failure marking is unchanged._csv.Dialect, reader, and writer, with 8 fields and 18 values per field. Baseline differs on 242 cases; patched semantic outcomes match all 432. The remaining 21 text-only differences are 18 preexisting validation-error wordings and 3 generic Rust integer-overflow messages versus CPython's C-int wording.This does not change the preexisting non-ASCII delimiter limitation, native-dialect identity behavior, or unrelated CSV parsing/writing paths. Broad Rust runtime suites were not executed; only focused CSV runtime checks and compile-only aggregates are used.
Additional checks passed:
cargo clippy --locked --release -p rustpython-stdlib --all-targets -- -D warningscargo test --locked --release --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi --no-runcrates/capi:cargo test --locked --release --no-runAI assistance
OpenAI Codex assisted with the audit, implementation, regression tests, and validation. The runtime checks above were actually executed in the Linux environment; no untested platform behavior is claimed.