except clause syntax question

Chris Angelico rosuav at gmail.com
Tue Jan 31 19:53:48 EST 2012


On Wed, Feb 1, 2012 at 9:03 AM, Duncan Booth
<duncan.booth at invalid.invalid> wrote:
> Abitrarily nested tuples of exceptions cannot contain loops so the code
> simply needs to walk through the tuples until it finds a match.

Is this absolutely guaranteed? The C API for CPython provides:
(Py2) http://docs.python.org/c-api/tuple.html#PyTuple_SetItem
(Py3) http://docs.python.org/dev/c-api/tuple.html#PyTuple_SetItem

which doesn't have massive warnings on it saying "USE THIS ONLY TO
INITIALIZE A TUPLE" (compare, for instance, _PyTuple_Resize which does
carry a similar warning). Is the assumption then that we're all
adults, and that mutating a tuple is like passing a null pointer to an
API function (aka "loaded gun in proximity to foot")?

ChrisA



More information about the Python-list mailing list