libsyntax: Forbid escapes in the inclusive range \x80-\xff in

Unicode characters and strings.

Use `\u0080`-`\u00ff` instead. ASCII/byte literals are unaffected.

This PR introduces a new function, `escape_default`, into the ASCII
module. This was necessary for the pretty printer to continue to
function.

RFC #326.

Closes #18062.

[breaking-change]
This commit is contained in:
Patrick Walton
2014-10-27 09:13:51 -07:00
parent bb70ee56db
commit e8d6031c71
12 changed files with 4276 additions and 4191 deletions

View File

@@ -283,7 +283,7 @@ def load_east_asian_width(want_widths, except_cats):
return widths
def escape_char(c):
if c <= 0xff:
if c <= 0x7f:
return "'\\x%2.2x'" % c
if c <= 0xffff:
return "'\\u%4.4x'" % c