From e9cc5f2f1545e9e8987b0dc4a9bae4ea00382db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Tarroja=20Caubet?= Date: Wed, 26 Mar 2025 18:09:18 +0100 Subject: [PATCH] Open CSV export file using with newline translation The csv documentation [1] explains that file object used in writer should be opened with newline as empty string. [1] https://docs.python.org/3/library/csv.html Closes #12115 (grafted from c07aae86c7fe87715994f0e82177980b9907dc3f) --HG-- branch : 6.0 --- tryton/tryton/gui/window/form.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tryton/tryton/gui/window/form.py b/tryton/tryton/gui/window/form.py index 3d642ab74b..936e3c325e 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -458,7 +458,7 @@ class Form(SignalEvent, TabContent): delimiter = ';' fileno, fname = tempfile.mkstemp( '.csv', common.slugify(export['name']) + '_') - with open(fname, 'w') as fp: + with open(fname, 'w', newline='') as fp: writer = csv.writer(fp, delimiter=delimiter) writer.writerow(fields) for row, path in zip_longest(data, paths or []):