Browse Source

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
Thomas Colthurst 7 years ago
parent
commit
79700b56b9
1 changed files with 9 additions and 0 deletions
  1. 9 0
      python/google/protobuf/pyext/message_module.cc

+ 9 - 0
python/google/protobuf/pyext/message_module.cc

@@ -130,6 +130,15 @@ extern "C" {
       Py_DECREF(m);
       Py_DECREF(m);
       return INITFUNC_ERRORVAL;
       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
 #if PY_MAJOR_VERSION >= 3
     return m;
     return m;