diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-23 01:32:45 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-23 01:32:45 +0000 |
commit | eef5f8396dd527c17ab7e419ca8781052031d05d (patch) | |
tree | 037edb4d4c12cc8e2c94a9c0ac765b89035ce71b /python/google/protobuf/text_format.py | |
parent | 35d2f017a7a685d700a8899d06d709cbffaaa885 (diff) |
Same as r275 except for Python.
Diffstat (limited to 'python/google/protobuf/text_format.py')
-rwxr-xr-x | python/google/protobuf/text_format.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py index 889aa836..c5713b63 100755 --- a/python/google/protobuf/text_format.py +++ b/python/google/protobuf/text_format.py @@ -298,7 +298,7 @@ class _Tokenizer(object): '[a-zA-Z_][0-9a-zA-Z_+-]*|' # an identifier '[0-9+-][0-9a-zA-Z_.+-]*|' # a number '\"([^\"\n\\\\]|\\\\.)*(\"|\\\\?$)|' # a double-quoted string - '\'([^\"\n\\\\]|\\\\.)*(\'|\\\\?$)') # a single-quoted string + '\'([^\'\n\\\\]|\\\\.)*(\'|\\\\?$)') # a single-quoted string _IDENTIFIER = re.compile('\w+') _INTEGER_CHECKERS = [type_checkers.Uint32ValueChecker(), type_checkers.Int32ValueChecker(), @@ -530,6 +530,12 @@ class _Tokenizer(object): Raises: ParseError: If a byte array value couldn't be consumed. """ + list = [self.ConsumeSingleByteString()] + while len(self.token) > 0 and self.token[0] in ('\'', '"'): + list.append(self.ConsumeSingleByteString()) + return "".join(list) + + def ConsumeSingleByteString(self): text = self.token if len(text) < 1 or text[0] not in ('\'', '"'): raise self._ParseError('Exptected string.') |