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
fe7d9379
Commit
fe7d9379
authored
Aug 14, 2015
by
Dan O'Reilly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing some long/int bugs
Signed-off-by:
Dan O'Reilly
<
oreilldf@gmail.com
>
parent
6654e77f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
12 deletions
+21
-12
decoder.py
python/google/protobuf/internal/decoder.py
+5
-2
reflection_test.py
python/google/protobuf/internal/reflection_test.py
+5
-5
type_checkers.py
python/google/protobuf/internal/type_checkers.py
+7
-4
text_format.py
python/google/protobuf/text_format.py
+4
-1
No files found.
python/google/protobuf/internal/decoder.py
View file @
fe7d9379
...
...
@@ -86,6 +86,9 @@ import struct
import
six
if
six
.
PY3
:
long
=
int
from
google.protobuf.internal
import
encoder
from
google.protobuf.internal
import
wire_format
from
google.protobuf
import
message
...
...
@@ -157,8 +160,8 @@ def _SignedVarintDecoder(mask, result_type):
# alternate implementations where the distinction is more significant
# (e.g. the C++ implementation) simpler.
_DecodeVarint
=
_VarintDecoder
((
1
<<
64
)
-
1
,
int
)
_DecodeSignedVarint
=
_SignedVarintDecoder
((
1
<<
64
)
-
1
,
int
)
_DecodeVarint
=
_VarintDecoder
((
1
<<
64
)
-
1
,
long
)
_DecodeSignedVarint
=
_SignedVarintDecoder
((
1
<<
64
)
-
1
,
long
)
# Use these versions for values which must be limited to 32 bits.
_DecodeVarint32
=
_VarintDecoder
((
1
<<
32
)
-
1
,
int
)
...
...
python/google/protobuf/internal/reflection_test.py
View file @
fe7d9379
...
...
@@ -630,17 +630,17 @@ class ReflectionTest(unittest.TestCase):
TestGetAndDeserialize
(
'optional_int32'
,
1
,
int
)
TestGetAndDeserialize
(
'optional_int32'
,
1
<<
30
,
int
)
TestGetAndDeserialize
(
'optional_uint32'
,
1
<<
30
,
int
)
try
:
integer_64
=
long
except
NameError
:
# Python3
integer_64
=
int
if
struct
.
calcsize
(
'L'
)
==
4
:
# Python only has signed ints, so 32-bit python can't fit an uint32
# in an int.
TestGetAndDeserialize
(
'optional_uint32'
,
1
<<
31
,
int
)
TestGetAndDeserialize
(
'optional_uint32'
,
1
<<
31
,
long
)
else
:
# 64-bit python can fit uint32 inside an int
TestGetAndDeserialize
(
'optional_uint32'
,
1
<<
31
,
int
)
try
:
integer_64
=
long
except
NameError
:
# Python3
integer_64
=
int
TestGetAndDeserialize
(
'optional_int64'
,
1
<<
30
,
integer_64
)
TestGetAndDeserialize
(
'optional_int64'
,
1
<<
60
,
integer_64
)
TestGetAndDeserialize
(
'optional_uint64'
,
1
<<
30
,
integer_64
)
...
...
python/google/protobuf/internal/type_checkers.py
View file @
fe7d9379
...
...
@@ -49,6 +49,9 @@ __author__ = 'robinson@google.com (Will Robinson)'
import
six
if
six
.
PY3
:
long
=
int
from
google.protobuf.internal
import
decoder
from
google.protobuf.internal
import
encoder
from
google.protobuf.internal
import
wire_format
...
...
@@ -195,13 +198,13 @@ class Uint32ValueChecker(IntValueChecker):
class
Int64ValueChecker
(
IntValueChecker
):
_MIN
=
-
(
1
<<
63
)
_MAX
=
(
1
<<
63
)
-
1
_TYPE
=
int
_TYPE
=
long
class
Uint64ValueChecker
(
IntValueChecker
):
_MIN
=
0
_MAX
=
(
1
<<
64
)
-
1
_TYPE
=
int
_TYPE
=
long
# Type-checkers for all scalar CPPTYPEs.
...
...
@@ -211,9 +214,9 @@ _VALUE_CHECKERS = {
_FieldDescriptor
.
CPPTYPE_UINT32
:
Uint32ValueChecker
(),
_FieldDescriptor
.
CPPTYPE_UINT64
:
Uint64ValueChecker
(),
_FieldDescriptor
.
CPPTYPE_DOUBLE
:
TypeChecker
(
float
,
int
,
int
),
float
,
int
,
long
),
_FieldDescriptor
.
CPPTYPE_FLOAT
:
TypeChecker
(
float
,
int
,
int
),
float
,
int
,
long
),
_FieldDescriptor
.
CPPTYPE_BOOL
:
TypeChecker
(
bool
,
int
),
_FieldDescriptor
.
CPPTYPE_STRING
:
TypeChecker
(
bytes
),
}
...
...
python/google/protobuf/text_format.py
View file @
fe7d9379
...
...
@@ -39,6 +39,9 @@ import re
import
six
if
six
.
PY3
:
long
=
int
from
google.protobuf.internal
import
type_checkers
from
google.protobuf
import
descriptor
from
google.protobuf
import
text_encoding
...
...
@@ -813,7 +816,7 @@ def ParseInteger(text, is_signed=False, is_long=False):
# alternate implementations where the distinction is more significant
# (e.g. the C++ implementation) simpler.
if
is_long
:
result
=
int
(
text
,
0
)
result
=
long
(
text
,
0
)
else
:
result
=
int
(
text
,
0
)
except
ValueError
:
...
...
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