Title: csv: apply dialect quoting and lineterminator in writer by jinmay · Pull Request #8254 · RustPython/RustPython · GitHub
Open Graph Title: csv: apply dialect quoting and lineterminator in writer by jinmay · Pull Request #8254 · RustPython/RustPython
X Title: csv: apply dialect quoting and lineterminator in writer by jinmay · Pull Request #8254 · RustPython/RustPython
Description: Closes #8253 This PR follows our AI policy Summary csv.writer ignored the quoting and lineterminator defined by a dialect (passed by name like dialect='unix' or as a dialect object), so writing with a built-in dialect diverged from CPython. Only explicit keyword arguments took effect. to_writer now resolves both from the dialect (via get_quoting() / get_lineterminator(), mirroring the existing get_delimiter()), while an explicit keyword argument still overrides it. While fixing this I also found the QuoteStyle::Minimal → csv_core mapping was Always (quoting every field under QUOTE_MINIMAL); it is now Necessary. This was dormant because the quote style was only applied for an explicit quoting= argument, so it had to be fixed before applying the dialect's quoting. import csv, io sio = io.StringIO() csv.writer(sio, dialect='unix').writerow([1, 'abc def', 'abc']) # before: '1,abc def,abc\r\n' # after: '"1","abc def","abc"\n' (matches CPython) Test plan Unmarks TestDialectUnix.test_simple_writer and Test_Csv.test_write_quoting (both @unittest.expectedFailure before). cargo run --release -- -m test test_csv: 128 run, 7 skipped, SUCCESS. extra_tests/snippets/stdlib_csv.py: passes. cargo fmt --check / cargo clippy: clean (no new warnings). Compared against real CPython 3.14.6 on the same machine; the outputs for the dialect='unix' and QUOTE_MINIMAL cases match. Assisted-by: Claude Code:claude-opus-4-8 Summary by CodeRabbit Bug Fixes Corrected minimal CSV quoting so values are quoted only when necessary. Improved CSV formatting to consistently respect the selected dialect’s line terminator and quoting settings. Ensured explicitly configured formatting options take precedence over dialect defaults.
Open Graph Description: Closes #8253 This PR follows our AI policy Summary csv.writer ignored the quoting and lineterminator defined by a dialect (passed by name like dialect='unix' or as a dialect object), so w...
X Description: Closes #8253 This PR follows our AI policy Summary csv.writer ignored the quoting and lineterminator defined by a dialect (passed by name like dialect='unix' or as a dialect objec...
Opengraph URL: https://github.com/RustPython/RustPython/pull/8254
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:02145399-c7b8-a589-449f-942593ee9d46 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B3B6:13907A:14F67E8:1EA5AF4:6A609B80 |
| html-safe-nonce | 9d5600654ff280ea5e8d7dae119615e54f6939d934802b2c6bed3a8b484b710c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0I2OjEzOTA3QToxNEY2N0U4OjFFQTVBRjQ6NkE2MDlCODAiLCJ2aXNpdG9yX2lkIjoiOTQ0MDc2MjYwNjA3MzAyNTI4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e61be75ab31aefd226e6721f010510df7e5d84bfa689966122c31d4430546227 |
| hovercard-subject-tag | pull_request:4034450204 |
| 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/8254/files |
| twitter:image | https://avatars.githubusercontent.com/u/13075035?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13075035?s=400&v=4 |
| og:image:alt | Closes #8253 This PR follows our AI policy Summary csv.writer ignored the quoting and lineterminator defined by a dialect (passed by name like dialect='unix' or as a dialect object), so w... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5142d23feb6a650085422edf60d68c93777dfa6c4b0c9151eb464d3e4969f618 |
| 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 | b2111e158bcd758ab9d0446577ae8f5dd78fcca8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width