[python-win32] PyIMAPIProp.GetPropList() and Py_None ref count
Nick Czeczulin
nick at packetfrenzy.com
Tue Aug 25 16:35:46 CEST 2015
On 8/24/2015 2:10 AM, Mark Hammond wrote:
> On 13/08/2015 8:20 PM, Nick Czeczulin wrote:
>> I noticed that every call to PyIMAPIProp.GetPropList() causes the ref
>> count for Py_None to increase by one. Can someone comment on whether the
>> following patch seems correct, or if more might be needed?
>
> At face value it looks wrong, but I'm not sure without more digging what
> the correct fix is, or why all other SWIG-based types don't have the
> same issue. I'm getting to most of your other issues on SourceForge and
> I suspect I wont find time to dig deeper on this before I make another
> release as the consequences of this seem fairly small (I'm sure None has
> many reference leaks :)
I've since submitted a patch after identifying the following in
pythoncom.i without clarifying in the patch description (only noting the
methods impacted):
%typemap(python,out) HRESULT {
$target = Py_None;
Py_INCREF(Py_None);
}
It can be verified in the generated .cpp file (See: GetPropsList):
{
_resultobj = Py_None;
Py_INCREF(Py_None);
}
{
_resultobj = PyMAPIObject_FromSPropTagArray(*_arg1);
Also, browsing mapilib.i's typemaps, only some test $target and call
Py_DECREF(), so the HRESULT typemap might be affecting some of the other
mapi calls as well for other output types. But, I definitely understand
your point on it being better to leak a Py_None ref than the alternative
due to a misunderstanding on my part.
Regarding my other outstanding patches, please ignore #138 for now --
I'd like to update it to be consistent with the updates you made for the
PT_MV_BINARY (#137) patch.
Thanks,
-nick
>
> Cheers,
>
> Mark
>>
>> Thanks,
>> -nick
>>
>> --- a/com/win32comext/mapi/src/mapilib.i
>> +++ b/com/win32comext/mapi/src/mapilib.i
>> @@ -501,6 +501,8 @@
>> }
>>
>> %typemap(python,argout) SPropTagArray **OUTPUT {
>> + if ($target == Py_None)
>> + Py_DECREF($target);
>> $target = PyMAPIObject_FromSPropTagArray(*$source);
>> if ($target==NULL) {
>> $cleanup;
>>
>>
>> _______________________________________________
>> python-win32 mailing list
>> python-win32 at python.org
>> https://mail.python.org/mailman/listinfo/python-win32
>>
>
More information about the python-win32
mailing list