votes up 4

String missing ending quote: %r

Package:
Exception Class:
self.ParseError

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,))

    try:
      result = text_encoding.CUnescape(text[1:-1])
    except ValueError as e:
      raise self.ParseError(str(e))
    self.NextToken()
    return result
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 1 votes down

Summary:

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"])
tok._ConsumeSingleByteString()

Working Version (Fixed):

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

Add a possible fix

Please authorize to post fix