Re: [Python-Dev] questions about memory management

2012年4月28日 11:16:39 -0700

Hello Julia,
On 2012年4月28日 10:06:52 +0200 (CEST)
Julia Lawall <[email protected]> wrote:
> In Python-3.2.3/Python/import.c, in the function 
> _PyImport_FixupExtensionUnicode, is any call to PyDict_DelItemString 
> needed before the final failure returns?
I would say it probably does, but it would need further examination.
Some error-checking code paths in our C code base may lack proper
cleanup, especially when an error is unlikely.
Could you open an issue at http://bugs.python.org with this?
> In Python-3.2.3/Modules/ossaudiodev.c, in the function build_namelists, is 
> it intentional that labels is not freed in the last failure case:
The successful call to PyModule_AddObject() steals a reference to
`labels`, so it doesn't need to be decrefed again (the reference is
not owned by the init function anymore).
Regards
Antoine.
> if (PyModule_AddObject(module, "control_labels", labels) == -1)
> goto error2;
> if (PyModule_AddObject(module, "control_names", names) == -1)
> goto error1;
> 
> return 0;
> 
> error2:
> Py_XDECREF(labels);
> error1:
> Py_XDECREF(names);
> return -1;
> 
> thanks,
> julia
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to