Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 541 by Double decode in google.protobuf.text_format._CUnescape

What steps will reproduce the problem?

  >>> print google.protobuf.text_format._CUnescape('\\x5c')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/google/protobuf/", line 691, in _CUnescape
      return result.decode('string_escape')
  ValueError: Trailing \ in string

What is the expected output? What do you see instead?

The expected output is a single backslash. _CUnescape works if the input is instead given in octal:

  >>> print google.protobuf.text_format._CUnescape('\\134')

When the input is given in hex the escaped backslash is unescaped _twice_, once in the re.sub() and once in the str.decode().

I'm not using the trunk HEAD but I can see that the issue is still present.

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to