From 79700b56b99fa5c8c22ddef78e6c9557ff711379 Mon Sep 17 00:00:00 2001 From: Thomas Colthurst Date: Tue, 3 Jul 2018 16:52:27 -0400 Subject: [PATCH] Update message_module.cc (#4835) * Update message_module.cc Add missing piece from pull request #4698: actually initialize the new API object. * Update message_module.cc --- python/google/protobuf/pyext/message_module.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/google/protobuf/pyext/message_module.cc b/python/google/protobuf/pyext/message_module.cc index f5c8f2956e..8c93386695 100644 --- a/python/google/protobuf/pyext/message_module.cc +++ b/python/google/protobuf/pyext/message_module.cc @@ -130,6 +130,15 @@ extern "C" { Py_DECREF(m); return INITFUNC_ERRORVAL; } + + // Adds the C++ API + if (PyObject* api = + PyCapsule_New(new ApiImplementation(), + google::protobuf::python::PyProtoAPICapsuleName(), NULL)) { + PyModule_AddObject(m, "proto_API", api); + } else { + return INITFUNC_ERRORVAL; + } #if PY_MAJOR_VERSION >= 3 return m;