[Pyrex] Regression in 0.9.6.3 when raising an exception in __len__
John Arbash Meinel
john at arbash-meinel.com
Fri Nov 16 21:00:27 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I have a custom __len__ implementation for one of my classes. Under certain
conditions it can raise an exception. With Pyrex 0.9.6.3 my exception is
getting silently ignored.
Looking at the generated .c code, I can see that 0.9.4.1 and 0.9.5.? have the
error handlers looking like:
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1:;
__Pyx_AddTraceback("Class.__len__");
__pyx_r = -1;
__pyx_L0:;
Py_DECREF(__pyx_v_self);
return __pyx_r;
However, in 0.9.6.3 the "__pyx_r = -1;" line has been removed.
If I add it back manually, my tests pass again.
I'm guessing that __len__ returning -1 is how it indicates an exception case
(like other functions return NULL to indicate an exception.)
I'm thinking that probably the Py_ssize_t changes caused some warnings, so
someone just removed that line, rather than doing something like:
__pyx_r = (Py_ssize_t) -1;
(Though -1 should be valid as a signed size_t so I don't know why it would be a
warning.)
Is there a reason this was changed?
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHPfbbJdeBCYSNAAMRAkAzAJ0QvlPpexyKg6+ODq+J78p4pgheMgCgj5gA
u4BQ4Ly2D+0VedjrJPJAeNw=
=dTEF
-----END PGP SIGNATURE-----
More information about the Pyrex
mailing list