Match CPython quotechar escaping when doublequote is disabled (#8953)

Let quote-only fields use the existing unquoted escaping path and enable
the existing CPython regression test.

Tested: test_csv, CSV snippet, 240 CPython comparisons, workspace and C-API tests, Clippy, prek
Assisted-by: Codex:gpt-6.1-sol
This commit is contained in:
Kwak Byoung Min authored and GitHub committed 2026-10-04 13:53:35 +09:00
1 parent 5b3e2a40e2
commit f39b054b9c
2 files changed
+1 -2

No files matched your search

-1
View File
@@ -228,7 +228,6 @@ class Test_Csv(unittest.TestCase):
self._write_test(['a','',None,1], '"a","",,"1"',
quoting = csv.QUOTE_NOTNULL)
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_write_escape(self):
self._write_test(['a',1,'p,q'], 'a,1,"p,q"',
escapechar='\\')
+1 -1
View File
@@ -1246,7 +1246,7 @@ mod _csv {
fn field_needs_quotes(data: &[u8], dialect: &PyDialect) -> bool {
data.iter().any(|&byte| {
byte == dialect.delimiter
|| dialect.quotechar == Some(byte)
|| (dialect.doublequote && dialect.quotechar == Some(byte))
|| matches!(byte, b'\r' | b'\n')
}) || data_contains_lineterminator_char(data, dialect)
}