mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#15927: Fix cvs.reader parsing of escaped \r\n with quoting off.
This fix means that such values are correctly roundtripped, since cvs.writer already does the correct escaping. Patch by Michael Johnson.
This commit is contained in:
parent
04cbe0c35b
commit
c7c42efb16
4 changed files with 25 additions and 1 deletions
|
@ -308,6 +308,15 @@ class Test_Csv(unittest.TestCase):
|
|||
for i, row in enumerate(csv.reader(fileobj)):
|
||||
self.assertEqual(row, rows[i])
|
||||
|
||||
def test_roundtrip_escaped_unquoted_newlines(self):
|
||||
with TemporaryFile("w+", newline='') as fileobj:
|
||||
writer = csv.writer(fileobj,quoting=csv.QUOTE_NONE,escapechar="\\")
|
||||
rows = [['a\nb','b'],['c','x\r\nd']]
|
||||
writer.writerows(rows)
|
||||
fileobj.seek(0)
|
||||
for i, row in enumerate(csv.reader(fileobj,quoting=csv.QUOTE_NONE,escapechar="\\")):
|
||||
self.assertEqual(row,rows[i])
|
||||
|
||||
class TestDialectRegistry(unittest.TestCase):
|
||||
def test_registry_badargs(self):
|
||||
self.assertRaises(TypeError, csv.list_dialects, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue