Skip to content
Snippets Groups Projects
Commit ff5639fd authored by Damien George's avatar Damien George
Browse files

Merge pull request #451 from lurch/repr-fixes

Display \r and \t escape codes in string repr
parents 97790455 12968fb6
Branches
No related tags found
No related merge requests found
...@@ -63,7 +63,10 @@ void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *e ...@@ -63,7 +63,10 @@ void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *e
print(env, "%c", *s); print(env, "%c", *s);
} else if (*s == '\n') { } else if (*s == '\n') {
print(env, "\\n"); print(env, "\\n");
// TODO add more escape codes here if we want to match CPython } else if (*s == '\r') {
print(env, "\\r");
} else if (*s == '\t') {
print(env, "\\t");
} else { } else {
print(env, "\\x%02x", *s); print(env, "\\x%02x", *s);
} }
......
# anything above 0xa0 is printed as Unicode by CPython3.3
for c in range(0xa1):
print("0x%02x: %s" % (c, repr(chr(c))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment