votes up 4

String missing ending quote: %r

Exception Class:

Raise code

      ParseError: When the wrong format data is found.
    text = self.token
    if len(text) < 1 or text[0] not in _QUOTES:
      raise self.ParseError('Expected string but found: %r' % (text,))

    if len(text) < 2 or text[-1] != text[0]:
      raise self.ParseError('String missing ending quote: %r' % (text,))

      result = text_encoding.CUnescape(text[1:-1])
    except ValueError as e:
      raise self.ParseError(str(e))
    return result
🙏 Scream for help to Ukraine
Today, 14th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Ways to fix

votes up 1 votes down


This exception occurs when an Instance of Tokenizer is created and the _ConsumeStingleByteString function is called. When creating an instance of the Tokenizer object, you must pass in a list of Strings. These strings must each have open and closing quotation marks around them. If one of them doesn't have a closing quotation mark then this exception is thrown. It doesn't matter if you use single or double quotes to declare the value as a string as long as the opposite type is inside of it.

Code to Reproduce the Error (WRONG):

from google.protobuf.text_format import Tokenizer
# Hello missing end quote
tok = Tokenizer(['"Hello','"Fix"', "'Exception"])

Working Version (Fixed):

from google.protobuf.text_format import Tokenizer
# Hello has both quotes
tok = Tokenizer(['"Hello"','"Fix"', "'Exception"]) 
Jul 10, 2021 codingcomedyig answer

Add a possible fix

Please authorize to post fix