File 0001-Fixed_the_KeepReference_function_annotation_when.patch of Package python-sip.2072
# HG changeset patch
# User Phil Thompson <phil@riverbankcomputing.com>
# Date 1391520766 0
# Node ID 2737c3074f4db5030f6e268916b836a9d37bae8a
# Parent fb6dbd80297bd18f14076ad3a35ca126401895f6
Fixed the /KeepReference/ function annotation when applied to static functions.
diff -r fb6dbd80297b -r 2737c3074f4d sipgen/gencode.c
--- a/sipgen/gencode.c Tue Feb 04 13:31:55 2014 +0000
+++ b/sipgen/gencode.c Tue Feb 04 13:32:46 2014 +0000
@@ -12648,8 +12648,8 @@
if (keepReference(res))
prcode(fp,
"\n"
-" sipKeepReference(sipSelf, %d, sipResObj);\n"
- , res->key);
+" sipKeepReference(%s, %d, sipResObj);\n"
+ , (isStatic(od) ? "NULL" : "sipSelf"), res->key);
/*
* Keep a reference to any argument with the result if the function is
diff -r fb6dbd80297b -r 2737c3074f4d sphinx/annotations.rst
--- a/sphinx/annotations.rst Tue Feb 04 13:31:55 2014 +0000
+++ b/sphinx/annotations.rst Tue Feb 04 13:32:46 2014 +0000
@@ -698,6 +698,10 @@
:aanno:`KeepReference` argument annotation when applied to the type of the
value returned by the function.
+ If the function is a class method or an ordinary function then the
+ reference is not kept by any other object and so the returned value will
+ never be garbage collected.
+
.. function-annotation:: KeywordArgs