PyModule_AddObject steals a reference. Fix all of the double calls to it by adding a Py_INCREF. Also, some other assorted hacks which probably shouldn't be necessary but are at the moment.
diff --git a/src/ssl/context.c b/src/ssl/context.c
index ebaf164..ce23f95 100644
--- a/src/ssl/context.c
+++ b/src/ssl/context.c
@@ -1299,6 +1299,9 @@
return 0;
}
+ /* PyModule_AddObject steals a reference.
+ */
+ Py_INCREF((PyObject *)&ssl_Context_Type);
if (PyModule_AddObject(module, "Context", (PyObject *)&ssl_Context_Type) < 0) {
return 0;
}