L4XB commented on code in PR #45614:
URL: https://github.com/apache/superset/pull/45614#discussion_r4345950619
##########
superset/utils/csv.py:
##########
@@ -115,7 +116,13 @@ def escape_values(v: Any) -> Union[str, Any]:
if isinstance(value, str):
df.at[label, name] = escape_value(value)
- return df.to_csv(escapechar="\\", **kwargs)
+ # An escape character makes the writer double every backslash in the data
+ # (C:\Users becomes C:\\Users). Only QUOTE_NONE, which cannot quote a
+ # delimiter or a line break, needs one; Python 3.10's writer also wanted
one
+ # for a NUL character (#28755), which Python 3.11 writes without it.
+ if kwargs.get("quoting") == QUOTE_NONE:
+ kwargs.setdefault("escapechar", "\\")
Review Comment:
Fixed in 5a0fcb8da. Under `quoting=QUOTE_NONE`, an `escapechar` of `None`
now counts as unset, and the default `\\` applies. Any other explicit
`escapechar` from `CSV_EXPORT` is still used as given.
`test_df_to_escaped_csv_keeps_backslashes` now checks that `escapechar=None`
gives the same output as leaving it out. On the previous commit, that case
raised `need to escape, but no escapechar set`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]