[Python-Dev] Catching exceptions and convert them to warnings in C level code (was: Re: Pronouncement needed in issue9675)
Jesus Cea
jcea at jcea.es
Sat Oct 2 22:14:28 CEST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 28/09/10 18:00, Antoine Pitrou wrote:
> By "fails" you mean "crashes the interpreter".
> While the deprecation warning can be discussed, bsddb shouldn't crash
> when PyCObject_FromVoidPtr() returns NULL, but instead bail out
> cleanly (or perhaps even ignore the error and simply display a warning
> that the C API won't be available).
I plan to deploy two patches for this issue. One, bsddb surviving the
warning->error flag. The other, changing the deprecation warning in
"CObject" to a py3k warning.
While doing this, I think would be useful if bsddb could intercept the
exception and provide sensible feedback without raising an exception at
import time. I have checked
<http://docs.python.org/c-api/exceptions.html>. "PyErr_Fetch" is a bit
overkill, it seems.
My idea is to convert the CObject exception in bsddb to print a warning
like "CObject creation failed. The bsddb.cAPI will be not available.
Reason is: XXXX".
Is there a "canonical way" of doing this?. Sorry if the answer is trivial...
- --
Jesus Cea Avion _/_/ _/_/_/ _/_/_/
jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/
jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/
. _/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQCVAwUBTKeSpJlgi5GaxT1NAQIMkgP9FCFewuhLHzExwi+aMSuevb56aoFOrBSE
q/XKN+9JxE59n2BwxgaJtUBrBdUraLe17SswgVgjxzReHKI+eNgC1fTwvDV+KqGa
9AMvlNGBfNCLP/TcSRzIGc9w0MsZaS8MvBKJWw+4hINclcp4a/AgxkCxc9sbm/dM
ATijPsG0RPY=
=qAIG
-----END PGP SIGNATURE-----
More information about the Python-Dev
mailing list