Add csv writer tests for QUOTE_STRINGS and QUOTE_NOTNULL edge cases
Bug description
Lib/test/test_csv.py already covers the basic writer behavior for csv.QUOTE_STRINGS and csv.QUOTE_NOTNULL, but it does not explicitly exercise a couple of edge cases for these newer quoting modes:
quotechar=Noneshould be rejected when quoting is enabled forQUOTE_STRINGSandQUOTE_NOTNULL, just likeQUOTE_ALL.- quoted fields using these modes should continue to handle embedded quote characters and escape characters correctly, including the
doublequote=Falsepath.
These are small conformance checks for behavior already implemented in _csv, and they help alternative Python implementations catch regressions around the newer quote styles.
Reproducer / expected behavior
import csv from io import StringIO for quoting in (csv.QUOTE_STRINGS, csv.QUOTE_NOTNULL): try: csv.writer(StringIO(), quoting=quoting, quotechar=None) except TypeError: pass else: raise AssertionError("quotechar=None should be rejected")
csv.writer should also preserve the existing escaping behavior for QUOTE_STRINGS and QUOTE_NOTNULL when escapechar is configured and doublequote is toggled.
CPython versions tested on
- CPython main branch
Operating systems tested on
- macOS