Skip to content

Commit ec79ab7

Browse files
committed
initialize quotechar when self.escapechar is not None even if self.quoting is csv.QUOTENONE
1 parent f2f24a9 commit ec79ab7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/io/formats/csvs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def __init__(
9090
self.index_label = self._initialize_index_label(index_label)
9191
self.errors = errors
9292
self.quoting = quoting or csvlib.QUOTE_MINIMAL
93-
self.quotechar = self._initialize_quotechar(quotechar)
9493
self.doublequote = doublequote
9594
self.escapechar = escapechar
95+
self.quotechar = self._initialize_quotechar(quotechar)
9696
self.lineterminator = lineterminator or os.linesep
9797
self.date_format = date_format
9898
self.cols = self._initialize_columns(cols)
@@ -141,7 +141,7 @@ def _get_index_label_flat(self) -> Sequence[Hashable]:
141141
return [""] if index_label is None else [index_label]
142142

143143
def _initialize_quotechar(self, quotechar: str | None) -> str | None:
144-
if self.quoting != csvlib.QUOTE_NONE:
144+
if self.quoting != csvlib.QUOTE_NONE or self.escapechar is not None:
145145
# prevents crash in _csv
146146
return quotechar
147147
return None

0 commit comments

Comments
 (0)