Issue #16145: Support legacy strings in the _csv module.
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 55796a2..96f8aa7 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -197,6 +197,17 @@
fileobj.seek(0)
self.assertEqual(fileobj.read(), "a,b\r\nc,d\r\n")
+ @support.cpython_only
+ def test_writerows_legacy_strings(self):
+ import _testcapi
+
+ c = _testcapi.unicode_legacy_string('a')
+ with TemporaryFile("w+", newline='') as fileobj:
+ writer = csv.writer(fileobj)
+ writer.writerows([[c]])
+ fileobj.seek(0)
+ self.assertEqual(fileobj.read(), "a\r\n")
+
def _read_test(self, input, expect, **kwargs):
reader = csv.reader(input, **kwargs)
result = list(reader)