aboutsummaryrefslogtreecommitdiff
path: root/python/google/protobuf/pyext/message.cc
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2015-10-05 13:54:05 -0700
committerJisi Liu <jisi.liu@gmail.com>2015-10-05 13:54:05 -0700
commit8d8177c75701014dfe27fec4cdd2b1647aefcb67 (patch)
treefdc5d0d0f2fd57f2ca641069c20b34ddf90ec919 /python/google/protobuf/pyext/message.cc
parent46e8ff63cb67a6520711da5317aaaef04d0414d0 (diff)
parentcccf6fed7e2fad1240bb48ba0c47f3978ff7433d (diff)
downloadprotobuf-8d8177c75701014dfe27fec4cdd2b1647aefcb67.tar.gz
protobuf-8d8177c75701014dfe27fec4cdd2b1647aefcb67.tar.bz2
protobuf-8d8177c75701014dfe27fec4cdd2b1647aefcb67.zip
Merge remote-tracking branch 'origin/master' into fix-author
Diffstat (limited to 'python/google/protobuf/pyext/message.cc')
-rw-r--r--python/google/protobuf/pyext/message.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
index 63d53136..9318c834 100644
--- a/python/google/protobuf/pyext/message.cc
+++ b/python/google/protobuf/pyext/message.cc
@@ -2893,6 +2893,14 @@ bool InitProto2MessageModule(PyObject *m) {
}
Py_INCREF(mutable_mapping);
+#if PY_MAJOR_VERSION >= 3
+ PyObject* bases = PyTuple_New(1);
+ PyTuple_SET_ITEM(bases, 0, mutable_mapping.get());
+
+ ScalarMapContainer_Type =
+ PyType_FromSpecWithBases(&ScalarMapContainer_Type_spec, bases);
+ PyModule_AddObject(m, "ScalarMapContainer", ScalarMapContainer_Type);
+#else
ScalarMapContainer_Type.tp_base =
reinterpret_cast<PyTypeObject*>(mutable_mapping.get());
@@ -2902,6 +2910,7 @@ bool InitProto2MessageModule(PyObject *m) {
PyModule_AddObject(m, "ScalarMapContainer",
reinterpret_cast<PyObject*>(&ScalarMapContainer_Type));
+#endif
if (PyType_Ready(&ScalarMapIterator_Type) < 0) {
return false;
@@ -2910,6 +2919,12 @@ bool InitProto2MessageModule(PyObject *m) {
PyModule_AddObject(m, "ScalarMapIterator",
reinterpret_cast<PyObject*>(&ScalarMapIterator_Type));
+
+#if PY_MAJOR_VERSION >= 3
+ MessageMapContainer_Type =
+ PyType_FromSpecWithBases(&MessageMapContainer_Type_spec, bases);
+ PyModule_AddObject(m, "MessageMapContainer", MessageMapContainer_Type);
+#else
Py_INCREF(mutable_mapping);
MessageMapContainer_Type.tp_base =
reinterpret_cast<PyTypeObject*>(mutable_mapping.get());
@@ -2920,6 +2935,7 @@ bool InitProto2MessageModule(PyObject *m) {
PyModule_AddObject(m, "MessageMapContainer",
reinterpret_cast<PyObject*>(&MessageMapContainer_Type));
+#endif
if (PyType_Ready(&MessageMapIterator_Type) < 0) {
return false;