summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-03-15 08:46:20 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-03-15 08:46:20 +0000
commitdea0c3f0b245a52861a9a813b22b1fc9959c0dcc (patch)
tree2ec4b2e5d48f1f273d9d7f1a5069299cf6df9580
parentae8aa4e08faadc03054058d3dc797400b0cfa412 (diff)
downloadswig-dea0c3f0b245a52861a9a813b22b1fc9959c0dcc.tar.gz
Add some code comments about Python objects and capsule reference counting
Issue #2208
-rw-r--r--Lib/python/pyrun.swg3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index 2ed650f08..3d3443946 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -998,6 +998,9 @@ SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
sobj->dict = 0;
#endif
if (own == SWIG_POINTER_OWN) {
+ /* Obtain a reference to the Python capsule wrapping the module information, so that the
+ * module information is correctly destroyed after all SWIG python objects have been freed
+ * by the GC (and corresponding destructors invoked) */
Py_XINCREF(Swig_Capsule_global);
}
}