Commits

Ned Batchelder committed 2270dbe

C can't handle Unicode escapes in identifiers, scrub them.

Comments (0)

Files changed (2)

             if tok.startswith("'"):
                 guts = re.sub(r"\\.|.", escape_quotes, tok[1:-1])
                 tok = '"' + guts + '"'
+        elif name == 'id':
+            # C can't deal with Unicode escapes in identifiers.  We don't
+            # need them for gettext anyway, so replace them with something
+            # innocuous
+            tok = tok.replace("\\", "U");
         c.append(tok)
     return ''.join(c)
 for (var x = a in foo && "</x>" || mot ? z:"REGEX"/i) {xyz(x++);}
 for (var x = a in foo && "</x>" || mot ? z/x:3;x<5;y<"REGEX") {xyz(x++);}
 ========================================
+\u1234xyz = gettext('Hello there');
+--------------------
+Uu1234xyz = gettext("Hello there");
+========================================
 """