• Kirill Smelkov's avatar
    encoder: Fix protocol 0 UNICODE emission · 619b90f8
    Kirill Smelkov authored
    Previously, we were quoting UNICODE opcode argument with strconv.QuoteToASCII().
    However that function, in addition to \u and \U escapes, can produce
    e.g. \n, \r, \xAA etc escapes. And all of the latter variants are not
    treated as special escapes of a unicode literal by Python, thus leading
    to data being wrongly received.
    
    Fix it by doing exactly the same that Python pickle encoder does - the
    UNICODE argument comes are "raw-unicode-escape" encoded.
    
    This patch contains only codec tests - not end-to-end pickle tests,
    because currently Encoder.encodeUnicode() is called only from under
    Encoder.encodeString(), and there only from under
    
    	if e.config.Protocol >= 3
    
    We will indirectly add tests for encodeUnicode @ protocol=0 in the next
    patches, while adding support for Python bytes.
    619b90f8
encode.go 11.6 KB