Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Lib/test/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,20 @@ def test_ordered_dict_reader(self):
OrderedDict([('fname', 'John'), ('lname', 'Cleese')]),
])

class HugeDataTest(unittest.TestCase):
def test_write_huge_data(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should probably be guarded with support.requires("largefile", ...) so that it only runs when the resource is enabled via python -m test -u largefile

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to test this, 2GB files are too much for this kind of change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not disagreeing, but would you mind elaborating on why we shouldn't test this, just for future reference? 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are rather hard to reason about. I would put it this way: since it is a very slow and heavy test that tests an integer overflow. It is not specific to any arch / os / runtime / etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the explanation :)

bad_size = 2 * 1024 * 1024 * 1024 + 1 # Just over 2GB
val = 'x' * bad_size
with TemporaryFile("w", encoding="utf-8", newline='') as fileobj:
csv_writer = csv.writer(fileobj, delimiter=',',
quotechar='|',
quoting=csv.QUOTE_MINIMAL)
csv_writer.writerow([val])
fileobj.seek(0)
reader = csv.reader(fileobj)
row = next(reader)
self.assertEqual(len(row), 1)


class MiscTestCase(unittest.TestCase):
def test__all__(self):
Expand Down
2 changes: 1 addition & 1 deletion Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ join_append_data(WriterObj *self, int field_kind, const void *field_data,
int copy_phase)
{
DialectObj *dialect = self->dialect;
int i;
Py_ssize_t i;
Py_ssize_t rec_len;

#define INCLEN \
Expand Down
Loading