summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-11-02 13:44:20 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-11-02 13:44:20 (GMT)
commite6996ed5d9c3ce149a8384a625521ab5a0820ae3 (patch)
tree3a650836587ea15ec283efa03418422da466e384 /Lib/test
parented71918d1297c9d478e497c783520d46b2bc0ee4 (diff)
downloadcpython-e6996ed5d9c3ce149a8384a625521ab5a0820ae3.zip
cpython-e6996ed5d9c3ce149a8384a625521ab5a0820ae3.tar.gz
cpython-e6996ed5d9c3ce149a8384a625521ab5a0820ae3.tar.bz2
Issue #16145: Support legacy strings in the _csv module.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_csv.py11
1 files changed, 11 insertions, 0 deletions
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 @@ class Test_Csv(unittest.TestCase):
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)