(c)
| 1115 | Returns the tuple (string literal to write, possible quote types). |
| 1116 | """ |
| 1117 | def escape_char(c): |
| 1118 | # \n and \t are non-printable, but we only escape them if |
| 1119 | # escape_special_whitespace is True |
| 1120 | if not escape_special_whitespace and c in "\n\t": |
| 1121 | return c |
| 1122 | # Always escape backslashes and other non-printable characters |
| 1123 | if c == "\\" or not c.isprintable(): |
| 1124 | return c.encode("unicode_escape").decode("ascii") |
| 1125 | return c |
| 1126 | |
| 1127 | escaped_string = "".join(map(escape_char, string)) |
| 1128 | possible_quotes = quote_types |
nothing calls this directly
no test coverage detected