Replace Py_XDECREF with Py_CLEAR in cleanup_python?

Kalle Olavi Niemitalo <[email protected]>
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
src/scripting/python/core.c:

void
cleanup_python(struct module *module)
{
	if (Py_IsInitialized()) {
		python_done_keybinding_interface();
		Py_XDECREF(python_hooks);
		Py_Finalize();
	}
}

Now if the Python scripting module is initialized once and
cleaned up, and then initialized again but the second
initialization fails e.g. because of invalid syntax in hooks.py,
I believe python_hooks will retain the value from the first
successful initialization.  And if the module is then again
cleaned up, Py_XDECREF gets called on an object that has already
been deleted.  A similar problem seems possible in
python_done_keybinding_interface.

Should the Py_XDECREF calls be changed to Py_CLEAR, or did I
misunderstand something?

I suppose this won't be a problem before enhancement request 73
(plugins support, http://bugzilla.elinks.cz/show_bug.cgi?id=73)
is implemented, but anyway fixing it seems easier than writing it
down for later.

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
signature.asc (application/pgp-signature, 188 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFFefOjHm9IGt60eMgRAnUBAKCL7L6nOaUt/KkkyfwbiJBVxNWLAQCfdX/S
G5sztZtcRXpvgRVA05GxuRY=
=+mAk
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.