(c)
| 536 | Returns the tuple (string literal to write, possible quote types). |
| 537 | """ |
| 538 | def escape_char(c): |
| 539 | # \n and \t are non-printable, but we only escape them if |
| 540 | # escape_special_whitespace is True |
| 541 | if not escape_special_whitespace and c in "\n\t": |
| 542 | return c |
| 543 | # Always escape backslashes and other non-printable characters |
| 544 | if c == "\\" or not c.isprintable(): |
| 545 | return c.encode("unicode_escape").decode("ascii") |
| 546 | return c |
| 547 | |
| 548 | escaped_string = "".join(map(escape_char, string)) |
| 549 | possible_quotes = quote_types |
nothing calls this directly
no test coverage detected