aboutsummaryrefslogtreecommitdiffhomepage
path: root/python/google
diff options
context:
space:
mode:
authorGravatar Jie Luo <anandolee@gmail.com>2017-07-19 16:25:05 -0700
committerGravatar GitHub <noreply@github.com>2017-07-19 16:25:05 -0700
commitbba4c4ae51b0c02bb72de98d7953a47c16146161 (patch)
tree49ccb71bf9078c8e7525c790b9fbff48cddf80b1 /python/google
parentaa61bb0d3cee089c37da32584d03132177dd847c (diff)
parent4987ddac75e650a9f659394f7161ab91e0e5a144 (diff)
Merge pull request #3262 from snnn/master
Make it compatible with python 3.6.1
Diffstat (limited to 'python/google')
-rw-r--r--python/google/protobuf/pyext/message.cc6
-rw-r--r--python/google/protobuf/pyext/repeated_composite_container.cc3
-rw-r--r--python/google/protobuf/pyext/repeated_scalar_container.cc7
3 files changed, 11 insertions, 5 deletions
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
index 85aaa46f..49113c7c 100644
--- a/python/google/protobuf/pyext/message.cc
+++ b/python/google/protobuf/pyext/message.cc
@@ -1055,13 +1055,15 @@ int InternalDeleteRepeatedField(
if (PySlice_Check(slice)) {
from = to = step = slice_length = 0;
- PySlice_GetIndicesEx(
#if PY_MAJOR_VERSION < 3
+ PySlice_GetIndicesEx(
reinterpret_cast<PySliceObject*>(slice),
+ length, &from, &to, &step, &slice_length);
#else
+ PySlice_GetIndicesEx(
slice,
-#endif
length, &from, &to, &step, &slice_length);
+#endif
if (from < to) {
min = from;
max = to - 1;
diff --git a/python/google/protobuf/pyext/repeated_composite_container.cc b/python/google/protobuf/pyext/repeated_composite_container.cc
index 9cb4e9a1..06a976de 100644
--- a/python/google/protobuf/pyext/repeated_composite_container.cc
+++ b/python/google/protobuf/pyext/repeated_composite_container.cc
@@ -266,10 +266,11 @@ int AssignSubscript(RepeatedCompositeContainer* self,
if (PySlice_Check(slice)) {
#if PY_MAJOR_VERSION >= 3
if (PySlice_GetIndicesEx(slice,
+ length, &from, &to, &step, &slicelength) == -1) {
#else
if (PySlice_GetIndicesEx(reinterpret_cast<PySliceObject*>(slice),
-#endif
length, &from, &to, &step, &slicelength) == -1) {
+#endif
return -1;
}
return PySequence_DelSlice(self->child_messages, from, to);
diff --git a/python/google/protobuf/pyext/repeated_scalar_container.cc b/python/google/protobuf/pyext/repeated_scalar_container.cc
index 95da85f8..9fedb952 100644
--- a/python/google/protobuf/pyext/repeated_scalar_container.cc
+++ b/python/google/protobuf/pyext/repeated_scalar_container.cc
@@ -305,10 +305,12 @@ static PyObject* Subscript(RepeatedScalarContainer* self, PyObject* slice) {
length = Len(self);
#if PY_MAJOR_VERSION >= 3
if (PySlice_GetIndicesEx(slice,
+ length, &from, &to, &step, &slicelength) == -1) {
#else
if (PySlice_GetIndicesEx(reinterpret_cast<PySliceObject*>(slice),
-#endif
length, &from, &to, &step, &slicelength) == -1) {
+
+#endif
return NULL;
}
return_list = true;
@@ -458,10 +460,11 @@ static int AssSubscript(RepeatedScalarContainer* self,
length = reflection->FieldSize(*message, field_descriptor);
#if PY_MAJOR_VERSION >= 3
if (PySlice_GetIndicesEx(slice,
+ length, &from, &to, &step, &slicelength) == -1) {
#else
if (PySlice_GetIndicesEx(reinterpret_cast<PySliceObject*>(slice),
-#endif
length, &from, &to, &step, &slicelength) == -1) {
+#endif
return -1;
}
create_list = true;