From 0d15eb28981142f181b0473055298de95ad261f9 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 21 Oct 2021 10:41:20 -0400 Subject: [PATCH] Workaround Python 3.10.0 CSV escape issue. Fixes #1437 --- src/gam/display.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gam/display.py b/src/gam/display.py index aa845274..1169da69 100644 --- a/src/gam/display.py +++ b/src/gam/display.py @@ -231,9 +231,14 @@ def write_csv_file(csvRows, titles, list_type, todrive): 'No columns selected with GAM_CSV_HEADER_FILTER and GAM_CSV_HEADER_DROP_FILTER\n' ) return - csv.register_dialect('nixstdout', - lineterminator='\n', - quoting=csv.QUOTE_MINIMAL) + nixstdout_dialect = {'lineterminator': '\n', + 'quoting': csv.QUOTE_MINIMAL} + # fix issue with Python 3.10.0 and no escape char + # 3.10.1+ may fix this within Python so hopefully + # this is short-lived. + if sys.version_info.minor >= 10: + nixstdout_dialect['escapechar'] = '\\' + csv.register_dialect('nixstdout', **nixstdout_dialect) if todrive: write_to = io.StringIO() else: