Title: Support csv writer QUOTE_STRINGS and QUOTE_NOTNULL by doma17 · Pull Request #8109 · RustPython/RustPython · GitHub
Open Graph Title: Support csv writer QUOTE_STRINGS and QUOTE_NOTNULL by doma17 · Pull Request #8109 · RustPython/RustPython
X Title: Support csv writer QUOTE_STRINGS and QUOTE_NOTNULL by doma17 · Pull Request #8109 · RustPython/RustPython
Description: Closes #8108 This PR follows our AI policy Summary Implements writer support for csv.QUOTE_STRINGS and csv.QUOTE_NOTNULL. These constants were already exposed, but using either quote style with csv.writer reached an internal todo!() and panicked. Problem csv.writer(..., quoting=csv.QUOTE_STRINGS) and csv.writer(..., quoting=csv.QUOTE_NOTNULL) should behave like CPython. Instead, RustPython converted these quote styles through an unimplemented path, so normal Python code could terminate the interpreter with a Rust panic. Fixes Route QUOTE_STRINGS and QUOTE_NOTNULL away from the todo!() writer path. Add Rust-side writer handling for both quote styles: QUOTE_STRINGS quotes original string fields and still quotes fields that require quoting because of delimiters, quote characters, or line endings. QUOTE_NOTNULL quotes every field except None. None is written as an empty unquoted field. Match CPython error behavior for a single empty field produced from None. Reject quotechar=None when quoting is enabled. Add regression coverage in extra_tests/snippets/stdlib_csv.py. Testing Verified the original reproducer no longer panics. Verified the new stdlib_csv regression with RustPython. Verified test_csv passes. Verified formatting/lint/pre-commit hooks. Verified the workspace test suite. AI use Assisted by codex gpt-5.5 for implementation and test drafting. I reviewed, edited, and verified the changes locally. Summary by CodeRabbit Bug Fixes Fixed CSV quoting/escaping for QUOTE_STRINGS and QUOTE_NOTNULL, ensuring fields are correctly quoted and special characters are handled per the active dialect. Improved validation around quoting options, including proper errors for invalid combinations and when quotechar is set to None. New Features Added more consistent CSV writer handling for these quoting modes to match expected rendered output. Tests Added in-memory buffer tests that verify exact CSV strings and confirm the expected exceptions for invalid configurations.
Open Graph Description: Closes #8108 This PR follows our AI policy Summary Implements writer support for csv.QUOTE_STRINGS and csv.QUOTE_NOTNULL. These constants were already exposed, but using either quote style with c...
X Description: Closes #8108 This PR follows our AI policy Summary Implements writer support for csv.QUOTE_STRINGS and csv.QUOTE_NOTNULL. These constants were already exposed, but using either quote style with c...
Opengraph URL: https://github.com/RustPython/RustPython/pull/8109
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:34634ba9-4adb-ed14-8482-5052996426e5 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E23A:38B79:9299AC:CB6EEB:6A604C7F |
| html-safe-nonce | d6f3f897dade05e9c295952a362f52444d9583c264909c68171cb2a8d50f3e28 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjNBOjM4Qjc5OjkyOTlBQzpDQjZFRUI6NkE2MDRDN0YiLCJ2aXNpdG9yX2lkIjoiMTIyNDM5MDMxMTk1Mjc5Njc5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 692d0af1a891c17ebd3edf38cf3d43cd4510ca8c9741f9f60b877d247b3055c4 |
| hovercard-subject-tag | pull_request:3867043666 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/8109/files |
| twitter:image | https://avatars.githubusercontent.com/u/67214970?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/67214970?s=400&v=4 |
| og:image:alt | Closes #8108 This PR follows our AI policy Summary Implements writer support for csv.QUOTE_STRINGS and csv.QUOTE_NOTNULL. These constants were already exposed, but using either quote style with c... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60da8c2a42fa2bbf5f7567474990ec467836a84444262a58e200fa91b7f3d2d0 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9824515e740d83d5eb82168a089b806ab0fe04a1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width