Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
4833b4c0
Commit
4833b4c0
authored
May 24, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Surrogate checking is unpredictable, so always manually check.
parent
bd98eae1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
24 deletions
+6
-24
failure_list_python.txt
conformance/failure_list_python.txt
+0
-16
json_format.py
python/google/protobuf/json_format.py
+6
-8
No files found.
conformance/failure_list_python.txt
View file @
4833b4c0
...
...
@@ -43,21 +43,5 @@ JsonInput.Uint32FieldMaxFloatValue.JsonOutput
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
JsonInput.ValueAcceptNull.JsonOutput
JsonInput.ValueAcceptNull.ProtobufOutput
ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
ProtobufInput.PrematureEofInPackedField.BOOL
ProtobufInput.PrematureEofInPackedField.DOUBLE
ProtobufInput.PrematureEofInPackedField.ENUM
ProtobufInput.PrematureEofInPackedField.FIXED32
ProtobufInput.PrematureEofInPackedField.FIXED64
ProtobufInput.PrematureEofInPackedField.FLOAT
ProtobufInput.PrematureEofInPackedField.INT32
ProtobufInput.PrematureEofInPackedField.INT64
ProtobufInput.PrematureEofInPackedField.SFIXED32
ProtobufInput.PrematureEofInPackedField.SFIXED64
ProtobufInput.PrematureEofInPackedField.SINT32
ProtobufInput.PrematureEofInPackedField.SINT64
ProtobufInput.PrematureEofInPackedField.UINT32
ProtobufInput.PrematureEofInPackedField.UINT64
TimestampProtoInputTooLarge.JsonOutput
TimestampProtoInputTooSmall.JsonOutput
python/google/protobuf/json_format.py
View file @
4833b4c0
...
...
@@ -69,10 +69,9 @@ _INFINITY = 'Infinity'
_NEG_INFINITY
=
'-Infinity'
_NAN
=
'NaN'
if
sys
.
version_info
<
(
3
,
0
):
_UNPAIRED_SURROGATE_PATTERN
=
re
.
compile
(
six
.
u
(
r'[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]'
))
_UNPAIRED_SURROGATE_PATTERN
=
re
.
compile
(
six
.
u
(
r'[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]'
))
class
Error
(
Exception
):
"""Top-level module error for json_format."""
...
...
@@ -559,13 +558,12 @@ def _ConvertScalarFieldValue(value, field, require_str=False):
elif
field
.
cpp_type
==
descriptor
.
FieldDescriptor
.
CPPTYPE_STRING
:
if
field
.
type
==
descriptor
.
FieldDescriptor
.
TYPE_BYTES
:
return
base64
.
b64decode
(
value
)
elif
sys
.
version_info
<
(
3
,
0
):
# Python 2.x does not detect unpaired surrogates when JSON parsing.
else
:
# Checking for unpaired surrogates appears to be unreliable,
# depending on the specific Python version, so we check manually.
if
_UNPAIRED_SURROGATE_PATTERN
.
search
(
value
):
raise
ParseError
(
'Unpaired surrogate'
)
return
value
else
:
return
value
elif
field
.
cpp_type
==
descriptor
.
FieldDescriptor
.
CPPTYPE_ENUM
:
# Convert an enum value.
enum_value
=
field
.
enum_type
.
values_by_name
.
get
(
value
,
None
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment